Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Converting rows to columns.

Converting rows to columns.

From: <kpraoasp_at_yahoo.com>
Date: 1 Aug 2006 07:04:20 -0700
Message-ID: <1154441060.258380.221550@75g2000cwc.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US