SQL Help? - TechRepublic
Question
November 17, 2008 at 12:22 PM
donallsop

SQL Help?

by donallsop . Updated 17 years, 7 months ago

I’m stumped on what seems to be a simple SQL query.

My data source is a table with fields Item, Date, and Quantity, like so:

ITEM DATE QTY
Apples 11/12/08 10
Apples 11/13/08 42
Pears 11/11/08 13
Bananas 11/12/08 21
Apples 11/10/08 8
Bananas 11/14/08 15
Pears 11/10/08 16

I want to return the quantity found in the record with the latest date for each item.
So the output would be

Apples 11/13/08 42
Bananas 11/14/08 15
Pears 11/11/08 13

I can’t figure this. I’m sure it will be obvious once somebody else tells me the answer.
TIA

This discussion is locked

All Comments