如何编写由学生分组的查询

时间:2015-03-09 04:29:35

标签: sql oracle

如何编写查询以选择student_id并汇总课程出勤金额,按学生分组

表:

SQL> desc attendances
 Name                                      Null?    Type
 ----------------------------------------- -------- -------------
 RUNNING_ID                                         NUMBER(5)
 STUDENT_ID                                         NUMBER(4)
 EVALUATION                                         VARCHAR2(1)
 AMOUNT_PAID                                        NUMBER(6,2)

我已经设法达到这一点,然后我遇到了错误:

SELECT SUM(AMOUNT_PAID)
FROM ATTENDANCES;

1 个答案:

答案 0 :(得分:2)

如果我说得对,这就是你想要的东西

SELECT student_id,SUM(AMOUNT_PAID)
FROM ATTENDANCES group by student_id;