Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Converting rows to columns.
Hi,
I need to know if there's any analytical function that will convert rows to columns. Currently, I have a query - select field1, field2, count(*) from table1 group by field1, field2 order by field1, field2
Obviously, this gives multiple rows for the same value of field1. What i need is one row for each value of field1 and field2 should appear as columns.
For example, if the output of the above query is
Field1 field2 count(*)
A 0412 12 A 0501 23 A 0502 25 B 0412 3 B 0501 56
I need the result to be
Field1 0412 0501 0502 A 12 23 25 B 3 56
Is that even possible? I thought there was an analytical function that did this but I dont seem to find it anywhere.
Any help will be greatly appreciated.
Thanks,
KP
Received on Tue Aug 01 2006 - 09:04:20 CDT