ID Date Name
__ ____ _____
1 1/2/2004 Store A
2 1/1/2004 Store A
3 1/3/2004 Store B
4 1/2/2004 Store B
Say I wanted to get the rows for the maximum dates for stores A and B
aka this record set..
ID Date Name
__ ____ _____
1 1/2/2004 Store A
3 1/3/2004 Store B
How would I got about doing this in sql?
thanks
-JimSELECT id, date, name
FROM SomeTable AS T
WHERE date =
(SELECT MAX(date)
FROM SomeTable
WHERE name = T.name)
--
David Portas
SQL Server MVP
--
No comments:
Post a Comment