SQL Query return rows horizontally
Posted on 2013-01-16
I was requested to modify a query/report to save paper.
The query looks up a series of serial numbers associated with an order and then lists them on a packing slip.
Right now the list shows every serial number individually per line. I want to be able to list 5 serial numbers per line before going to the next one.
Sample Table Data
SEQ_NUM | SERIAL_NUMBER | Order_Num
1 A1234 SO-123
2 A3253 SO-123
3 A5764 SO-123
4 A7654 SO-123
5 A0045 SO-123
ie. Instead of reporting this
I would prefer this:
A1234 A3253 A5764 A7654 A0045
Our product is grouped in boxes of 5 items.
So, line 1-5 would be in the first box, 6-10 in the next......... The sequence restarts for every order.
Any suggestions? Thanks.