首页 > 代码库 > mysql分组用法

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

  

mysql分组用法