select offid,max(time2) from 表 A group by offid B 经常遇到,表名:tmp.testtable
想变成:
select a.* from tmp.testtable a inner join (select usercode,max(time2)maxtime from tmp.testtable group by usercode ) b on a.usercode=b.usercode and a.time2=b.maxtime
Max 用法正常用法:select offid,max(time2) from表 Agroup by offidB 经常遇到,表名:tmp.testtable想变成:select a.* from tmp.testtable ainner join(select usercode,max(time2)maxtime from tmp.testtable group by u...