oracle - Convert columns to rows in SQL -
I have to type a query that takes the rows and converts it into columns - here's my table:
calculation fname lname id ----------------------------- 1 ABC DEF 20 2 PBR 20 3 ABC xyz 20 4 xyz xyz 20 1 ABC def 21 1 pkr xyz 22 2 ABC ABC 22
This is what I am attempting to produce:
id fname lname Fname lname fname lname fname lname -------------------------------------------- - --------------- 20 ABC DEFPPR Faucet ABC xyz xyz xyz 21 ABC DF Free Tap tap tap tap tap 22 ABC ABC Nail nail tap tap tap tap
The maximum value of the count for each ID 4. I am using Oracle 9i.
There is another person who may have some luck with you, I like @ thinkjet, but this Not sure how much decode cost (if it is more or less than below.
SELECT T1.ID, T1.fname, T1.lname, T2.fname, T2.lname , T3.fname, T3.lname, T4.fname, T4.lname table T1 left join table T2 on T.ID = T.ID and T2 COUT = 2 left pair table T3 on T.ID = T.ID and T3CUt = 3 Left job table T4 on T1. ED = t 4kaidi and T 4 C o t = 4 where T 1C Open = 1
Comments
Post a Comment