Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
Hello Friends,

I have a requirement that to show hierarchical records into the single record.
like i have table table1 with data:
 

emp_id old_status new status 
1      A          B
1      B          C
1      C          D
2      A          B
2      B          C
2      C          D
2      D          E

I want to show records in following manner:
 

emp_id status1 status2 status3 status4 status5
1      A       B       C       D
2      A       B       C       D    E

 
Thanks in advance
Rohan Lokhande
Posted 7-Apr-13 8:10am
rohu123388
Edited 7-Apr-13 8:11am
(no name)158.9K
v2
Comments
Zoltán Zörgő at 7-Apr-13 13:14pm
   
You have a really important field missing: the order of these records.
Can there be more than 5 status values?
ThePhantomUpvoter at 7-Apr-13 13:15pm
   
You would use a PIVOT.
Maciej Los at 7-Apr-13 13:35pm
   
Which aggregate function (MAX, COUNT, SUM) you'll use?
 
;)

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

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100