Back
I have a table like this...
CustomerID DBColumnName Data--------------------------------------1 FirstName Joe1 MiddleName S1 LastName Smith1 Date 12/12/20092 FirstName Sam2 MiddleName S2 LastName Freddrick2 Date 1/12/20093 FirstName Jaime3 MiddleName S3 LastName Carol3 Date 12/1/2009
CustomerID DBColumnName Data
--------------------------------------
1 FirstName Joe
1 MiddleName S
1 LastName Smith
1 Date 12/12/2009
2 FirstName Sam
2 MiddleName S
2 LastName Freddrick
2 Date 1/12/2009
3 FirstName Jaime
3 MiddleName S
3 LastName Carol
3 Date 12/1/2009
And I want this...
Is this possible using PIVOT?
CustomerID FirstName MiddleName LastName Date----------------------------------------------------------------------1 Joe S Smith 12/12/20092 Sam S Freddrick 1/12/20093 Jaime S Carol 12/1/2009
CustomerID FirstName MiddleName LastName Date
----------------------------------------------------------------------
1 Joe S Smith 12/12/2009
2 Sam S Freddrick 1/12/2009
3 Jaime S Carol 12/1/2009
You can try using the MAX aggregate, it will work.
If MAX of one value = that particular value...
In the above case, you can self join 5 times on customerid, which can be filtered by dbColumnName per table reference.
31k questions
32.8k answers
501 comments
693 users