Oracle Rows into Columns

Posted by user2904845 on Stack Overflow See other posts from Stack Overflow or by user2904845
Published on 2013-10-21T21:47:22Z Indexed on 2013/10/21 21:53 UTC
Read the original article Hit count: 188

Filed under:
|

Can someone help me design the query to get below o/p.

Data I have:

Table X:
Count Name Amount Days 
5     ABC  500    Day1
10    ABC  1000   Day2
3     BCD  100    Day1
4     BDC  200    Day2

Result I need:

Name  Count AmountDay1 Count AmountDay2
ABC   5     500         10   1000
BCD   3     100         4    200

etc

Is this Possible?

I tried something with the below query, but not getting the desired o/p

select * from X
pivot
(sum(amount) for days in ('Day1', 'Day2'))

Please help I'm using Oracle 11 G

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about oracle11g