Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Vertical result with Oracle SQL?
georgino.no1_at_gmail.com wrote:
> Hi guys,
> Here is what I need to get.
>
> Columns: Id, Name, Program, cost
> Data sample:
> 1, George, Program 1, $10
> 1, George, Program 2, $10
> 1, Peter, Program 1, $10
>
> The result line should looks like this:
> 1; George, Peter; Program 1, Program 2, $30
>
> Basically I need to concatenate Names and Programs and sum the cost
> for each ID
>
> I am stuck here; any idea would be greatly appreciated
>
> Thanks
> Georgino
What you need to a cross tabulation.
In any version of Oracle this can be done with DECODE. Since 9i with CASE and in 11g with PIVOT.
Demos in Morgan's Library at www.psoug.org.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Tue Sep 11 2007 - 17:21:01 CDT
![]() |
![]() |