/ Published in: SQL
A few examples of the GROUP_ID function.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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();
URL: http://www.databasestar.com/oracle-group_id