Link to home
Start Free TrialLog in
Avatar of Roberto Madro R.
Roberto Madro R.Flag for United States of America

asked on

SQL Query for Max Date

I got this SQL query that I'm running against a table to pick the latest date an item was sold (PurchaseDate), pick the customer that bought it along with other info, the thing is, an item can be returned by one customer and bought by another, so If I'm running Max date function and grouping on Customer, I'll get both customers, the one that returned the item and the one that bought it, and it's critical to bring the customer out in the query. I need to select the item (Unit_Serial_no) by the last date it was sold (PurchaseDate) by that customer, and ignore past customers that had that item as some point. Please advise.
Regards
User generated image
ASKER CERTIFIED SOLUTION
Avatar of awking00
awking00
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roberto Madro R.

ASKER

Thank you awking00, just what the doctor ordered.
Many thanks
You're welcome - glad to help.