-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path57 SQL Query Rollup.sql
More file actions
35 lines (20 loc) · 1009 Bytes
/
57 SQL Query Rollup.sql
File metadata and controls
35 lines (20 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
--Rollup
use Google
select * from employee
delete from employee where department = 'Duplicate'
update employee set department = 'Marketing' where department is null
--rollup is an extension for group by function.
select department, sum(salary) as Total_sal from employee group by department
select department, gender, sum(salary) as Total_sal from employee group by department, genderselect department, gender, sum(salary) as Total from employeegroup by rollup (department, gender)select coalesce(department, 'Sum'), coalesce(gender, 'Total') , sum(salary) as Total_salary from employee group by rollup(department, gender)select department , sum(salary) as Total_salary from employee group by departmentselect department , sum(salary) as Total_salary from employee group by rollup (department)select coalesce(department, 'Total sum'), sum(salary) as Total_salary from employeegroup by rollup(department)--Roundselect round(12.4567, 3)select round(12.4567, 2)select round(12.4567, 1)