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.
 rollup

Syntax:


SELECT Column_1,Column_2,
SUM(some_column) AS some_column
FROM table_name
GROUP BY ROLLUP (Column_1,Column_2,..)
ORDER BY column_1, Column_2;
click below button to copy the code. By - oracle tutorial - team

Example:

SELECT id, name,
SUM(salary) AS salary
FROM   wikitechy_employee
GROUP BY ROLLUP (id, name) 
ORDER BY id, name;
click below button to copy the code. By - oracle tutorial - team

Sample database:

  • For Better understanding we are using the wikitechy_employee table in order to show how the ROLLUP works.
 rollup in oracle
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql

Code Explanation:

 rollup in oracle
  • 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.

Output:

 oracle sql rollup
  1. 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.
  2. Rollup keyword actually groups the salary values of same id.
  3. 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”.
  4. Group by Roll up statement produces group subtotals from right to left and a grand total as “33000”.

This tutorial provides an indepth knowledge on the following items such as oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , mysql tutorial , sql tutorial for beginners , learn sql , oracle database tutorial , sql query tutorial , oracle dba tutorial , plsql tutorial , oracle tutorial pdf , oracle pl sql tutorial , oracle sql tutorial , sql tutorial point , oracle tutorial for beginners , learn oracle online free , learn oracle online , learning pl sql programming , learn sql online for free , sql learning online , dba oracle tutorial , oracle sql tutorial advanced , oracle 11g dba tutorial with examples , oracle online learning , oracle learning online , how to learn pl sql , sql coding tutorial , sql learning websites , sql basic learning

Related Searches to Oracle Rollup | Rollup