21.02.02

EDDIE Kim·2021년 2월 2일
0

KH

목록 보기
36/98


EXISTS

NOT EXISTS


SCALA SUBQUERY

INLINE VIEW


TOP-N 분석

--입사일이 빠른 순서로 6-10번째 사원 조회
select *
from(select emp_name, hire_date
       from employee
       order by hire_date asc) E
where rownum between 6 and 10; 
--위에꺼 가져다가 where절만 6 and 10으로 바꾼다고 안됨. 
rownum은 where절이 시작하면서 부여되고, where절이 끝나면 모든행에 대해 부여가 끝난다.
offset(건너뛰는것)이 있다면, 정상적으로 가져올 수 없다. 

select E.*
from (select rownum rnum, E.*
        from(select emp_name, hire_date
               from employee
               order by hire_date asc) E) E
where rnum between 6 and 10;
--inlineview를 한계층 더 사용해야 한다.

--직급이 대리인 사원중에 연봉 4-6순위 조회(순위, 이름, 연봉)
select E.*
from (select rownum rnum, E.*
        from (select emp_name, (salary + (salary * nvl(bonus, 0))) * 12 annual_salary
                from employee
                where job_code = (select job_code
                                          from job
                                          where job_name = '대리')
                order by annual_salary desc) E ) E
where rnum between 4 and 6;


WITH AS

WINDOW FUNCTION - 순위함수

WINDOW FUNCTION - 집계함수

profile
과거 지상직 / 개발자 지망생

0개의 댓글

관련 채용 정보