我有一个表,是有点像一个历史悠久的表......所以我有这样Sql Server的双重子查询
idA numberMov FinalDate
1 10 20090209
2 14 20090304
1 12 20090304
3 54 20080508
4 42 20090510
... ... ....
数据
我需要根据每个IDA的最新finalDate检索numberMov所以我用这个
select a.numberMov from (select idA, max(finalDate) maxDate from table1 group by idA) as b inner join table1 a on a.idA=b.idA and a.finalDate = b.maxDate
现在我有这样
select m fields from n tables where n5.numberMov in ("insert first query here")
我觉得有一个更好的另一个查询解决方案,但不能想到任何,我真的不喜欢有两个子查询在那里。
有什么建议吗?