■ CUBE 함수 : 자동으로 합계/소계 만들기

------------------------------------------------------------------------------------------------------------------------

SELECT

    COURSE_ID

   ,STUDENT_ID

   ,SUM(SCORE)

FROM SCORE

WHERE COURSE_ID = 'L0011'

GROUP BY CUBE(COURSE_ID, STUDENT_ID);

 

/*

COURSE_ID STUDENT_ID SUM(SCORE)

--------- ---------- ----------

                            166

          C0801              68

          C0802              98

L0011                       166

L0011     C0801              68

L0011     C0802              98

*/

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요