最近在写个分组查询获取最新时间戳的语句时,发现这样写挺受用的,分享之:
select * from test a where a.updatetime=(select max(b.updatetime) from test b where a.type=b.type)
ps:假设a是已经groupby之后的表。
最近在写个分组查询获取最新时间戳的语句时,发现这样写挺受用的,分享之:
select * from test a where a.updatetime=(select max(b.updatetime) from test b where a.type=b.type)
ps:假设a是已经groupby之后的表。