I have the below data and want to get the max date with all corresponding data:
sapid startdate number cstctr job
500032 02/10/2010 30001450 AR01000008 10000549
500032 04/01/2009 39000345 AR01000003 10000549
500032 09/16/2009 30001380 AR01000003 10000549
500032 09/29/2008 39000345 AR01000003 00000000
500032 12/01/2006 39000345 AR01000003 00000000
IF I do a "max" on all fields it returns:
500032 02/10/2010 39000345 AR01000008 10000549
which is the "max" on all fields, itdoesn't return the corresponding data for date "02/10/2010" (since that is the max record. If I only do a "max" on only the date field I have to group by the others therefore returning all data?
How can I write the below code:
SELECT
sapid, startdate, number, cstctr, job
from cust
where sapid = '500032'
To get these results based on the data provided above:
sapid startdate number cstctr job
500032 02/10/2010 30001450 AR01000008 10000549
Thanks a bunch!!
sapid startdate number cstctr job
500032 02/10/2010 30001450 AR01000008 10000549
500032 04/01/2009 39000345 AR01000003 10000549
500032 09/16/2009 30001380 AR01000003 10000549
500032 09/29/2008 39000345 AR01000003 00000000
500032 12/01/2006 39000345 AR01000003 00000000
IF I do a "max" on all fields it returns:
500032 02/10/2010 39000345 AR01000008 10000549
which is the "max" on all fields, itdoesn't return the corresponding data for date "02/10/2010" (since that is the max record. If I only do a "max" on only the date field I have to group by the others therefore returning all data?
How can I write the below code:
SELECT
sapid, startdate, number, cstctr, job
from cust
where sapid = '500032'
To get these results based on the data provided above:
sapid startdate number cstctr job
500032 02/10/2010 30001450 AR01000008 10000549
Thanks a bunch!!