select top 1 * from tabel1 where name='aa' order by date desc或:select * from tabel1 where name='aa' and date=(select max(date) from table1)
select top 1 * from tabel1 where name='aa' order by date desc 是可以的,而后面那一条 select * from tabel1 where name='aa' and date=(select max(date) from table1) 有问题吧。 应该是 select * from tabel1 where date=(select max(date) from table1 where name='aa')
是可以的,而后面那一条
select * from tabel1 where name='aa' and date=(select max(date) from table1)
有问题吧。
应该是
select * from tabel1 where date=(select max(date) from table1
where name='aa')
如果我要列出表中每个name字段值对应的最大日期怎么办?
假如上表中
我要得到:
date值为2003-05-01的aa这条记录和date值为2003-05-02的bb记录多谢多谢