Works like a charm. Thanks. To the previous comment about not doing it in SQL; The query is rather complex and returns a lot of other data I use for processing; Another db query I think slow things down.
Thanks for you help! I knew there was a more elegant way of doing this!