
-- gb_9.sql
-- original
-- incorrect use of NVL to detect NULL
-- as some NULLs are Superaggregate nulls

set autotrace off echo on

drop table my_emp;

create table my_emp
as
select * from scott.emp;

insert into my_emp(empno,ename,job,deptno) values(1024,'JKSTILL',NULL,NULL);
commit;

select
	nvl(ename,'SA_NULL') ename
	, nvl(job,'SA_NULL') job
	, nvl(deptno,0) deptno
from my_emp
group by cube(ename,job,deptno)

l

/

set echo off






