select aa.datetemp,max(ts) ts,max(aa.createTime) MaxcreateTime,MAX(id) id,MAX(code) code,MAX(sl) sl,Max(temp) temp from
(select convert(varchar(10),createTime,23) datetemp,DATEDIFF(DAY,createTime,GETDATE()) as ts,* from A
where DATEDIFF(DAY,createTime,GETDATE())<=30) aa
group by aa.datetemp
sql 查询最近30天每天最后录入的一条数据
最新推荐文章于 2024-04-18 18:57:41 发布