Click here to Skip to main content
11,926,429 members (57,912 online)
Rate this:
Please Sign up or sign in to vote.
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
Edited 7-Apr-13 8:11am
Maciej Los210.1K
Zoltán Zörgő 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 7-Apr-13 13:15pm
You would use a PIVOT.
Maciej Los 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2015
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