Author |
Topic |
Dannyj
Starting Member
2 Posts |
Posted - 2012-09-21 : 06:11:10
|
Hi all,Hope you can help, i need to display the following tableselect ID, Sort_Order, Code, start_date, end_datefrom table1ID, Sort_Order, Code, start_date, end_date1, 1, A555, 01/01/2012, 05/01/20121, 2, B666, 01/01/2012, 05/01/20122, 1, C777, 08/01/2012, 10/01/20122, 2, D111, 08/01/2012, 10/01/20123, 1, E222, 15/01/2012, 20/01/20123, 2, F333, 15/01/2012, 20/01/2012Like this;ID, Code 1, Code 2, start_date, end_date,1, A555, B666, 01/01/2012, 05/01/2012,2, C777, D111, 08/01/2012, 10/01/2012,3, E222, F333, 15/01/2012, 20/01/2012,The sort_order can range between 1 - 100Thanks for any helpDany |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2012-09-21 : 06:32:13
|
with Sas (select 1 as ID ,1 as SortOrder,'A555' as Code,'01/01/2012' as Start_date,'05/01/2012' as end_dateunion allselect 1, 2, 'B666', '01/01/2012', '05/01/2012'union allselect 2, 1, 'C777', '08/01/2012', '10/01/2012'union allselect 2, 2, 'D111', '08/01/2012', '10/01/2012'union allselect 3, 1, 'E222', '15/01/2012', '20/01/2012'union allselect 3, 2, 'F333', '15/01/2012', '20/01/2012')select * from Spivot (min(Code) for SortOrder in ([1],[2])) pfor 1--100 change in ([1],[2],...[100]) |
|
|
Dannyj
Starting Member
2 Posts |
Posted - 2012-09-21 : 08:24:33
|
Thanks very much for your help, thats exactly what i needed.Danny |
|
|
|
|
|