Home » SQL & PL/SQL » SQL & PL/SQL » Converting rows into column
Converting rows into column [message #207035] Mon, 04 December 2006 00:10 Go to next message
shyamjha
Messages: 11
Registered: September 2006
Location: Mumbai
Junior Member

Hi I have data as blow:
Month	Desc	Spent
1	CAP	127088
1	CBB	552344
1	CON	171080
1	FLR	492466
1	FME	733200
1	MDD	150306
1	MIS	830960
1	MRO	2340130
1	PAC	1148680
1	PLD	1390636
1	SRV	2220374
1	SSO	20774
1	SUP	3289624
1	XXX	9776
2	CAP	32994
2	CBB	576784
2	CON	183300
2	FLR	521794
2	FME	609778
2	MDD	97760
2	MIS	761306
2	MRO	2159274
2	PAC	1213446
2	PLD	1206114
2	SRV	2028520
2	SSO	19552
2	SUP	3664778
2	XXX	3666
3	CAP	4888
3	CBB	586560
3	CON	161304
3	FLR	563342
3	FME	729534
3	MDD	124644
3	MIS	830960
3	MRO	2767830
3	PAC	1092468
3	PLD	1511614
3	SRV	1963754
3	SSO	18330
3	SUP	3766204
3	WTR	1222
3	XXX	10998
4	CBB	6110
4	MIS	1222
4	MRO	8554
4	PLD	32994
4	SUP	13442
5	MDD	1222


Can any one help me in writing a SQL, PL/SQL query to get the
Output like as below:

Month	CAP	CBB	CON	FLR	FME	MDD	MIS	MRO	PAC	PLD	SRV	SSO	SUP	WTR	XXX
1	127088	552344	171080	492466	733200	150306	830960	2340130	1148680	1390636	2220374	20774	3289624		9776
2	32994	576784	183300	521794	609778	97760	761306	2159274	1213446	1206114	2028520	19552	3664778		3666
3	4888	586560	161304	563342	729534	124644	830960	2767830	1092468	1511614	1963754	18330	3766204	1222	10998
4		6110					1222	8554		32994			13442		


Thanks in advance.

Shyam

[Updated on: Mon, 04 December 2006 06:57] by Moderator

Report message to a moderator

Re: Converting rows into column [message #207157 is a reply to message #207035] Mon, 04 December 2006 06:09 Go to previous messageGo to next message
CoolBuddy
Messages: 10
Registered: December 2006
Location: India
Junior Member
check this link for the desired solution.

http://asktom.oracle.com/pls/ask/f?p=4950:8:9541489786234944912::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:15637744429336
Re: Converting rows into column [message #207169 is a reply to message #207157] Mon, 04 December 2006 06:58 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
CoolBuddy wrote on Mon, 04 December 2006 13:09
check this link for the desired solution.
I don't think the OP is looking for a concatenation solution. He wants to transpose the rows into true columns.

MHE
Re: Converting rows into column [message #207171 is a reply to message #207035] Mon, 04 December 2006 07:10 Go to previous message
CoolBuddy
Messages: 10
Registered: December 2006
Location: India
Junior Member
the link was wrong.
i apologise.
here is the correct one.

http://asktom.oracle.com/pls/ask/f?p=4950:8:14193227734352763057::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:766825833740
Previous Topic: select rows included in a sum
Next Topic: creation of Schema
Goto Forum:
  


Current Time: Sun Dec 04 08:42:15 CST 2016

Total time taken to generate the page: 0.07684 seconds