有如下表及数据
mysql> select * from student;
+----+------------------------+----------+-------------+--------+
| id | name | grade | gender | num |
+----+------------------------+----------+-------------+--------+
| 1 | 炸天帮徐缺 | 10 | M | 1 |
| 2 | 炸天帮孙悟空 | 99 | M | 2 |
| 3 | 炸天帮花无缺 | NULL | 0 | 3 |
| 4 | 炸天帮叶良辰 | 100 | M | 4 |
| 5 | 炸天帮二狗 | 20 | M | 5 |
| 6 | 炸天帮段九德 | 99 | M | 6 |
| 7 | 炸天帮薛之谦 | 60 | 0 | 7 |
+----+------------------------+----------+--------------+--------+
7 rows in set (0.03 sec)
创建一个名为FindZ的存储过程用于查询Student表中的相同成绩人数。
SELECT grade , COUNT(name) FROM student GROUP BY grade ;
网友评论