我有一张有几百条记录的表。比方说,它只有两个字段(ID
和DateModified
)。
我需要获取与表中最小DateModified
值匹配的所有记录。
例如,我有6条记录(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
查询应该返回记录345,346和348.我该怎么做?
答案 0 :(得分:4)
SELECT *
FROM table
WHERE DateModifiedvalue = (SELECT min(DateModifiedvalue)
FROM table1 )
答案 1 :(得分:1)
select top 1 with ties *
from YourTable
order by DateModified