Home » SQL & PL/SQL » SQL & PL/SQL » Rollup and NVL function toghether
Rollup and NVL function toghether [message #595] Sat, 23 February 2002 13:06 Go to next message
hshah22222
Messages: 6
Registered: February 2002
Junior Member
select deptno,nvl(job,'subtotal')as job,sum(sal) as salary
from emp
group by rollup(deptno,job)

how do you write grandtotal in the last line? thanks
Re: Rollup and NVL function toghether [message #599 is a reply to message #595] Sun, 24 February 2002 14:49 Go to previous message
sokeh
Messages: 77
Registered: August 2000
Member
try this:
i have not had time to test it:
select decode(grouping(deptno),0,to_char(deptno),'Grand Total')Deptno,
nvl(job,'subtotal') Job, sum(sal)salary
from emp
group by rollup(deptno,job)
Previous Topic: NEED HELP - ASAP! invalid host/bind variable name
Next Topic: Help, optimizing query
Goto Forum:
  


Current Time: Fri Sep 24 06:29:39 CDT 2021