我有一张表,它的数据如下所示:
id name date
--------- --------- ----------
1 a 2012-08-30 10:36:27.393
1 b 2012-08-30 14:36:27.393
2 c 2012-08-30 13:36:27.393
2 d 2012-08-30 16:36:27.393
我使用此查询检索最大日期时间:
select
t1.id
,t1.name
,t1.date
from
table1 t1
inner join (
SELECT id,Max(date) as mymaxdate
FROM table1
group by id
) mt1
on t1.id = mt1.id
and t1.date = mt1.mymaxdate
结果:
1 b 2012-08-30 14:36:27.393
2 d 2012-08-30 16:36:27.393
如何在实体中编写此查询?
谢谢