分组查询

select [Address],COUNT([Address] )  from Students group by [Address]
--分组之后没有具体的数据信息,只有组的信息
select gender,COUNT(age),MAX(age),MIN(age)from Students group by Gender--按照性别分组,统计组里面的个数,取出组里面的最大年龄和最小年龄
select Age from Students group by Age  having age>3  --having 对分组后的信息进行过滤
select age,COUNT(id) from Students group by Age having COUNT(id)>1

posted @ 2014-04-06 22:55  编程猴子  阅读(167)  评论(0编辑  收藏  举报