SQLP 자격증

[ORACLE] group by + cube

HR대장 2021. 8. 31. 16:36
728x90

select 
  case when grouping(emp_no) = '1'  then 'all emp no' else to_char(emp_no) end as 직원번호
, case when grouping(rel_type_cd) = '1' then 'all type cd' else to_char(rel_type_cd) end as 관계, count(*) as 가족수
from fam_c
group by cube( emp_no , rel_type_cd)
;

 

728x90