Thanks for that and I am actually using DB2 also.
I realise that when you do a simple select the order is maintained however I'm using a full outer join. So this orders the table fo me in the result. Even when I add an unsorted or order by clause it does not help. I really think that perl is my only option however if you can think of something within DB2 which would save me having top program it I would be delighted to hear about it.