mysql 数据知识小计(一)

分组统计,今天突然遇到了,以前老是弄错,记录一下。返回各组中大于各组平均值的记录:
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

猜你喜欢

转载自xiaofengyu.iteye.com/blog/1725736
今日推荐