rollup
[출처: http://cafe.daum.net/oraclesqltuning] 해당 테이블명을 t, 각 컬럼명을 pname(품명), psize(규격), qty(수량), amount(금액) 이라고 하면, 아래와 같이 되겠네요. SELECT pname_a, psize, qty, amount FROM (SELECT pname, DECODE (psize, NULL, pname) pname_a, psize, SUM (qty) qty, SUM (amount) amount, MAX (SUM (amount)) OVER (PARTITION BY pname) sub_max FROM t GROUP BY pname, ROLLUP ((psize, qty))) ORDER BY sub_max DESC, pname, amount DE..