SQL - Need help with nested join/syntax

I've got a table with a bunch of item records.  Some attributes of an item are a "date updated" field and a "price" field.
There may be multiple reocrds for each item, where the price can increase due to, say, inflation.

Here's a small example:

Item                     Date Updated                     Cost
Doll                       11.02.02                            $5.00
Doll                       12.04.03                            $5.50
Ball                       05.03.01                            $2.25
Ball                       02.26.04                            $2.75
...

What I need to do is extract one record for each item, but only the record with the most recent data (the latest date.)
So, I'd only want the 12.04.03 Doll record and the 02.26.04 Ball record.

What does the SQL look like for a query like this?


 
LVL 6
starfailureAsked:
Who is Participating?
 
acampomaConnect With a Mentor Commented:
select * from table1 a
where Date_Updated=(select max(Date_Updated) from Table1 where Item=a.item)
0
 
starfailureAuthor Commented:
that's what I needed.  thanks.

still getting accustomed to derived tables...
0
All Courses

From novice to tech pro — start learning today.