-
Transposing rows to columns
Posted on June 20th, 2007 No commentsToday, I saw a question in an orkut SQL forum where the guy wanted to transpose rows to columns.
I replied to it.
Let me explain about it.
See this snapshot. I do a query of my test2 table. There are 2 rows. And the 4 weekly data has to be extracted into single column.
See, there are 4 columns that need to be turned into 1 column in 4 rows. So we need to do a cartesian join 4 times. So I use this table below.
See the cartesian join done and the results. See that each ord_no appears 4 times.
Now, using decode, I am getting only what I need.

Leave a reply
You must be logged in to post a comment.





