sql案例四
— 需求:sql查询每组数据中时间最大的一条
select t2.* from (select t.name, max(t.dtime) dtime from test t group by name) t1 left join test t2 on t1.name=t2.name and t1.dtime=t2.dtime;
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 小仓鼠!
评论
— 需求:sql查询每组数据中时间最大的一条
select t2.* from (select t.name, max(t.dtime) dtime from test t group by name) t1 left join test t2 on t1.name=t2.name and t1.dtime=t2.dtime;