Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> create columns from rows in a query
I have a table like
Date Code N
01-01-2002 F1 4 01-01-2002 F2 7 01-01-2002 F3 8 01-02-2002 F1 1 01-02-2002 F2 3 01-02-2002 F3 9
I need to write a query that create this structure:
Date F1_N F2_N F3_N 01-01-2002 4 7 8 01-02-2002 1 3 9
That is, I need to put the information in column instead that rows.
I do it whit this query:
select date,
sum(decode(code,'F1',N,null)) F1_N, sum(decode(code,'F2',N,null)) F2_N, sum(decode(code,'F3',N,null)) F3_Nfrom table
Question is: can I optain this result using some SQL instruction I don't know?, without having to DECODE->SUM->Group by ? Received on Thu Feb 13 2003 - 02:55:53 CST
![]() |
![]() |