Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a scenario in which i need to transpose the columns to the rows.

select se.timestamp, e.description,se.created_by from status se, status_desc e where e.id=se.id and se.shipment_id=12550060 order by timestamp ;

O/P:
Timestamp Status Owner
12/12/2017 11:08 A system
12/12/2017 11:08 B system
12/12/2017 12:37 C system
12/12/2017 14:38 C system
12/12/2017 14:55 C system
12/12/2017 14:55 C system
12/12/2017 17:31 D A2A
12/13/2017 11:34 E A2A

I need to show this like (all rows to appear as columns):

Timestamp 1 Status 1 Owner 1 Timestamp 2 Status 2 Owner 2 Timestamp 3 Status 3 Owner 3 Timestamp 4 Status 4 Owner 4 Timestamp 5 Status 5 Owner 5 Timestamp 6 Status 6 Owner 6 Timestamp 7 Status 7 Owner 7 Timestamp 8 Status 8 Owner 8
12/12/2017 11:08 A system 12/12/2017 11:08 B system 12/12/2017 12:37 C system 12/12/2017 14:38 C system 12/12/2017 14:55 C system 12/12/2017 14:55 C system 12/12/2017 17:31 D A2A 12/13/2017 11:34 E A2A

What I have tried:

I have tried:
max(case when e.id = '1' then e.description end) but this thing only shows status 'C' once not 4 times.
Posted
Updated 7-Jan-18 8:24am
Comments
Santosh kumar Pithani 16-Dec-17 3:59am    
what is your expected output?i think you need to do pivot.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900