Can anyone help with this T-SQL request?
I have a table of 1000s of orders. Many are repeat orders for the same customer. I'm trying to create a query that would show many spend habits of each customer, and also the promotional code used on their first ever order. I can pick out their first order date by using Top or Max function, but how would i return just Cust and first Promotion code from table below?:
Cust Order Order Date Promotion Code
JB001 df445 01/02/2014 Web32
JB001 56456 01/02/2015 Cat85
JB001 5646a 03/04/2012 Email22
JB001 ff55f 25/04/2003 Cat67
JB002 45454 28/09/2011 Cat55
JB002 65488 22/10/2011 Email31
JB002 793gg 15/05/2007 Email22
JB003 5444h 10/10/2014 Web14
JB003 gbnm2 22/10/2014 Autumn21
to give this?:
Cust Promotion Code
JB001 Cat67
JB002 Email22
JB003 Web14
Many thanks in advance,
John