Return to Snippet

Revision: 71807
at March 14, 2017 15:50 by bbrumm


Initial Code
select * from student;

SELECT address_state,
TO_CHAR(enrolment_date, 'MON') AS enrolment_month,
SUM(fees_paid)
FROM student
GROUP BY address_state, TO_CHAR(enrolment_date, 'MON');


SELECT address_state,
TO_CHAR(enrolment_date, 'MON') AS enrolment_month,
SUM(fees_paid),
GROUP_ID()
FROM student
GROUP BY address_state, ROLLUP(address_state, TO_CHAR(enrolment_date, 'MON'))
ORDER BY address_state, TO_CHAR(enrolment_date, 'MON'), GROUP_ID();



SELECT address_state,
TO_CHAR(enrolment_date, 'MON') AS enrolment_month,
SUM(fees_paid),
GROUP_ID()
FROM student
GROUP BY address_state, ROLLUP(address_state, TO_CHAR(enrolment_date, 'MON'))
HAVING GROUP_ID() = 0
ORDER BY address_state, TO_CHAR(enrolment_date, 'MON'), GROUP_ID();

Initial URL
http://www.databasestar.com/oracle-group_id

Initial Description
A few examples of the GROUP_ID function.

Initial Title
Oracle GROUP_ID Function

Initial Tags
sql, Oracle

Initial Language
SQL