获取分组后取某字段最大的一条记录
原文:https://blog.****.net/chenaini119/article/details/78870511
查找每个接口访问量最大的记录
方法1
select * from 211_10_APICount as a
where count = (
select max(b.count)
from 211_10_APICount as b
where a.api = b.api );
方法2:
select * from (select * from 211_10_APICount order by count desc) as a group by a.api
方法一:
select * from (select * from table2 order by age desc) as a group by a.table1_id
1
方法二:
select a.* from table2 as a where age = (select max(age) from table2 where a.table1_id=table1_id)
1
方法三:
select a.* from table2 as a where not exists (select * from table2 where table1_id=a.table1_id and age>a.age)
1
方法四:
select a.* from table2 as a where exists (select count(*) from table2 where table1_id=a.table1_id and age>a.age having count(*)=0)
---------------------