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

方法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;

实测可行

原文地址:https://www.cnblogs.com/xiaoyuersdch/p/8945281.html