You didn't mention how you were getting your data, but it would seem that it is a grouping question, but it would seem that this doesn't yield a easy solution.
It would seem that you would want to normalize your data based on some other field, like the invoice number and then take your fields one at time. You will get more records, but the item number will be in the same spot. This should be easy in a stored procedure.
If you are joining straight to the tables, this probably won't work, and nothing comes to mind to get you around this issue.
You might try to create a formula that would group/order the values as you want and group on that.
Hope this helps