select a.city,(select value from table b on a.city=b.city and b.date=max(a.date)) from table a group by a.city
select * from table a,(select city,max(date) date from table ) b where a.city=b.city and a.date=b.date
select * from table a where a.date = (select max(date) from table b where a.city = b.city)
select tbname.* from tbname,(select city,max(date) m_date from tbname group by city) tbname2 where tbname.date = tbname2.m_date;
1、select * from table a where a.date = (select max(date) from table b where a.city = b.city)2、select tbname.* from tbname,(select city,max(date) m_date from tbname group by city) tbname2 where tbname.date = tbname2.m_date两种写法都可以,但是在数据量较大时,第一种可能会用较长时间。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货