Picking all records from a table that match smallest date
I have a table that has a few hundred records. Let's say, for simplicity, that it has only two fields (ID
and DateModified
).
I need to get all records that match t开发者_如何学Pythonhe smallest DateModified
value in the table.
For example, I have 6 records (ID / DateModified
):
ID DateModified
344 11-June-2011
345 5-June-2011
346 5-June-2011
347 20-June-2011
348 5-June-2011
349 16-June-2011
The query should return records 345, 346 and 348. How would I do this?
SELECT *
FROM table
WHERE DateModifiedvalue = (SELECT min(DateModifiedvalue)
FROM table1 )
select top 1 with ties *
from YourTable
order by DateModified
精彩评论