I am using sql server 2014
I wanted to get Id (identity) field for maximum date as per order status id
Customer - Order Table:
Id (identity) | Customer ID | Order Status ID | Order Date
10000 | 11 | 1 | 1 Feb 2017
10001 | 11 | 2 | 2 Feb 2017
10002 | 11 | 2 | 3 Feb 2017
10003 | 11 | 3 | 4 Feb 2017
10004 | 11 | 3 | 5 Feb 2017
Expected Result
Customer ID | 1 | 2 | 3
11 | 10000 |10002 | 10004
PIVOT
/UNPIVOT
directly, some have equivalent functions as extensions, and some require you to perform the process more manually. See stackoverflow.com/tags/pivot/infoOrder Status ID
a well-known different values? f.e. 1,2,3 or is it variable.