Hi,
I have the following data:
cust subject date
Cust1 Subject1 2010-12-31 21:59:59.000
Cust1 Subject1 2010-12-31 21:59:59.000
Cust4 Subject3 2011-02-27 21:59:59.000
Cust5 Subject1 2010-10-31 21:59:59.000
Cust5 Subject2 2010-10-31 21:59:59.000
Cust6 Subject2 2010-10-31 21:59:59.000
Cust6 Subject2 2010-12-31 21:59:59.000
I need to achieve the following:
- Group them by cust and subject
- If there are 2 records with the same cust and subject then i need to return the one with the highest date
- Following the above, if the dates are the same then return only 1 of them.
The result of the query should be:
cust subject date
Cust1 Subject1 2010-12-31 21:59:59.000
Cust4 Subject3 2011-02-27 21:59:59.000
Cust5 Subject1 2010-10-31 21:59:59.000
Cust5 Subject2 2010-10-31 21:59:59.000
Cust6 Subject2 2010-12-31 21:59:59.000
Can anyone help me with this?
I managed to do 2 of the requirements but not all 3.