Reputation: 4557
I need an sql select statement that would transform
1
2
3
4
into 1 2 3 4
Without using PIVOT functions as I am running oracle 10 database. Searched quite a lot on the Internet but surprisingly found nothing.
Little help?
Upvotes: 0
Views: 131
Reputation: 1269773
You can do a pivot
almost as efficiently using a cross join:
select max(case when seqnum = 1 then t.col end) as col1,
max(case when seqnum = 2 then t.col end) as col2,
max(case when seqnum = 3 then t.col end) as col3,
max(case when seqnum = 4 then t.col end) as col4
from (select t.*, row_number() over (order by NULL) as seqnum
from t
) t
Upvotes: 1