This is my query:
select d.department_id, d.department_name, sum(e.salary) AS total
from department d inner join employee e on d.department_id=e.department_id
group by d.department_id,d.department_name
I want the Grand total by sum of total column (the alias column). I get this by using this query:
select d.department_id, d.department_name, sum(e.salary) AS total
from department d inner join employee e on d.department_id=e.department_id
group by d.department_id,d.department_name WITH ROLLUP
But I want this by a another column, like using the sum function. Is it possible?
ROLLUP
work for you?