分组统计,今天突然遇到了,以前老是弄错,记录一下。返回各组中大于各组平均值的记录:
select c.*,b.m from signin_users c
inner join (SELECT a.usertype,avg(a.uid) as m FROM `signin_users` a group by a.usertype) as b on b.usertype = c.usertype
where c.uid >= b.m