-
Write a SQL to print the rows horizonatally
Write a SQL to print the rows horizonatally table consist of single field.
Question asked by visitor pooja
-
Contributing Member
Re: Write a SQL to print the rows horizonatally
try this -------------->>
with t as
(
(select 'a' col from dual)
union all
(select 'a' col from dual)
union all
(select 'a' col from dual)
union all
(select 'a' col from dual)
union all
(select 'a' col from dual)
)
select
max(decode(rn,1,col))col1,
max(decode(rn,2,col))col2,
max(decode(rn,3,col))col3,
max(decode(rn,4,col))col4,
max(decode(rn,5,col))col5
from
(select col,row_number() over(order by col)rn from t)
order by col
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules