Hi all,
I need to create a query which groups by two columns and returns an additional column based on a condition.
For example, say I've got the following columns:
ProductCode | SerialNumber | Quantity | DatePurchased | CustomerID
and the table contains duplicate combinations of ProductCode and SerialNumber with differing Quanitites and Purchase Dates. I'd like to return the ProductCode, SerialNumber and the Quantity for the row with greatest (most recent) value for DatePurchased. To further complicate things this must be done for all rows where CustomerID = 'xxx'.
Any ideas???
Any help appreciated. Cheers.