开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜