I have a query that gives me all customer's and their last three order dates.
EX:
CustomerId DateOrdered
167 2006-09-16 01:25:38.060
167 2006-09-21 13:11:53.530
171 2006-08-31 15:19:22.543
171 2006-09-01 13:30:54.013
171 2006-09-01 13:34:36.483
178 2006-09-04 11:36:19.983
186 2006-09-05 12:50:27.153
186 2006-09-05 12:51:08.513
I want to know if there is a way for me to pivot it to display like this:
[CustomerId] [Most Recent] [Middle] [Oldest]
'167' '2006-09-21 13:11:53.530' '2006-09-16 01:25:38.060' 'NULL'
'171' '2006-09-01 13:34:36.483' '2006-09-01 13:30:54.013' '2006-08-31 15:19:22.543'
'178' '2006-09-04 11:36:19.983' NULL NULL
'186' '2006-09-05 12:51:08.513' '2006-09-05 12:50:27.153' NULL