Select * from table order by city,date desc

解决方案 »

  1.   

    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
      

  2.   

    select * from table a,(select city,max(date) date from table ) b where a.city=b.city and a.date=b.date
      

  3.   

    select * from table a where a.date = (select max(date) from table b where a.city = b.city)
      

  4.   

    select tbname.* from tbname,(select city,max(date) m_date from tbname group by city) tbname2 where tbname.date = tbname2.m_date;
      

  5.   

    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两种写法都可以,但是在数据量较大时,第一种可能会用较长时间。