Oracle Rollup | Rollup - oracle tutorial - sql tutorial
What is Oracle Rollup ?
- ROLLUP enables the SELECT statement to calculate multiple levels of subtotals across the specific group of dimensions in the table. It also calculates the grand total in the table.
- ROLLUP is considered as the simple extension to the GROUP BY clause.
- For Better understanding we are using the wikitechy_employee table in order to show how the ROLLUP works.
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql
- Using select Statement we are selecting id and name column from the table wikitechy_employee.
- Sum (salary) function is used to find the sum of data values from salary column.
- Group by Roll up statement produces group subtotals from right to left and a grand total.
- Here, using select statement are selecting id and name column from the table wikitechy_employee along with the Sum (salary) function which is showing the sum of salary values for Jammy & Vinoth’s as 9500.
- Rollup keyword actually groups the salary values of same id.
- Considering the next ID 123, it doesn’t have any other ID value to add it up, so in the execution the select statement shows the output along with the sum (salary) function for the sum data value as “9000”.
- Group by Roll up statement produces group subtotals from right to left and a grand total as “33000”.