SQL中Group by 简单理解

版权声明:[email protected] https://blog.csdn.net/weixin_43198122/article/details/85037013

在sql语言中,我们常常想将查询出来的数据进行分组,这时我们就用到了Group by 函数。

eg:
有如下表:
student

序号 学号 姓名 性别
1 20161208001 张三
2 20161208002 李四
3 20161208003 王五

查询:

select 性别,count(性别) as 数量 from student group by 性别

结果为:

性别 数量
2
1

猜你喜欢

转载自blog.csdn.net/weixin_43198122/article/details/85037013
今日推荐