[SQL/Oracle] 5회 수업

Idel·2022년 12월 24일
0

기술블로그

목록 보기
14/38
  1. group by절

    /* 전체 집계도 '전체'라고 조회되지만 부서ID가 null인 부서의 집계도 '전체'라고 조회됨 */
    select decode(department_id, null, '전체', department_id), count(*)
    from employees
    group by rollup(department_id); 
    
    select decode(grouping(department_id), 1, '전체', department_id), count(*)
    from employees
    group by rollup(department_id); 
    

Reference

0개의 댓글