我在下面有这张表,我需要获取在考试中获得 A 的学生人数。这就是我想从下表中实现的目标:
3 A = 0 学生。2 A = 3 名学生。
+--------------+------------+------+
| student_ID | kod_subjek | gred |
+--------------+------------+------+
| 746123096687 | 02 | A |
| 746123096687 | 12 | B |
| 746123096687 | 21 | A |
| 860206145454 | 12 | A |
| 860206145454 | 02 | A |
| 881012085535 | 02 | A |
| 881012085535 | 21 | A |
+--------------+------------+------+
我尝试:
mysql> SELECT student_ID, COUNT(gred) FROM data_exam GROUP BY student_ID;
输出是:
+--------------+-------------+
| student_ID | COUNT(gred) |
+--------------+-------------+
| 746123096687 | 3 |
| 860206145454 | 2 |
| 881012085535 | 2 |
+--------------+-------------+
它不起作用。它只会计算特定学生的所有成绩。请帮我解决这个问题。谢谢你。