Wednesday 15 September 2010

oracle sql. transform one column into one row -


I need a SQL selection statement that needs to be changed

  1 2 3 4 < / Code> > 

In 1 2 3 4

Without using the PIVOT function, as I searched the Internet on the Internet I , But surprisingly nothing was found.

A little help?

You can efficiently use a pivot by using cross JOI: / P>

  Select Max (when SqNum = 1 then TOL end) col1, max (case when seqnum = 2 then TOL end) col2, Max (case when seqnum = 3 then t.col end) col3, max (case when seqnum = 4 then t.col end) to col4 (select t, *, from row_number ()) (sequence by null) seqnum From T to T) T    

No comments:

Post a Comment