mysql分组用法

--select num from 表 group by num
--select num from 表 group by num,nid


--特别的:group by 必须在where之后,order by之前
--select num,nid from 表  where nid > 10 group by num,nid order by nid desc


-- group by是关键
-- 可接多个分组的判断条件
--select num,nid,count(*),sum(score),max(score),min(score) from 表 group by num,nid


--select num from 表 group by num having max(id) > 10

  

posted @ 2017-05-26 11:23  Xiao|Deng  阅读(1051)  评论(0编辑  收藏  举报