从数据库表中查询日期最新的记录

方法1:select a.* from data_subtaskregionschedule a inner join(select subregionid,max(updatetime) maxupdatetime
from data_subtaskregionschedule group by subregionid) b on a.subregionid=b.subregionid and a.updatetime
=b.maxupdatetime;

方法2:select * from data_subtaskregionschedule,(select

subregionid,max(updatetime) maxdate from

data_subtaskregionschedule group
 by subregionid) t where

data_subtaskregionschedule.subregionid=t.subregionid and

data_subtaskregionschedule.updatetime=t.maxdate;

实测可行

posted @ 2018-04-25 15:53  就是小鱼儿  阅读(5687)  评论(0编辑  收藏  举报