SELECT
단일 row 단일 column
select employee_id, first_name
(select first_name
from employees
where employee_id = 100)
from employees;
FROM
다중 row 다중 column
select employee_id, first_name
from
(select employee_id, first_name, salary
from employees
where department_id = 60)
where salary > 10000;
WHERE
다중 row 다중 column
select first_name, salary
from employees
where salary > (select avg(salary) from employees);
+ROWNUM
조회순번 =순위매기기
SELECT RNUM, employee_id, first_name, salary
FROM (SELECT ROWNUM AS RNUM, employee_id, first_name, salary -- 2. 순번 결정
FROM
(SELECT employee_id, first_name, salary -- 1. 급여 많은순으로 정렬
FROM employees
ORDER BY salary DESC)
)
WHERE RNUM >= 11 AND RNUM <= 20; -- 3. 원하는 순번 범위지정
'BackEnd > RDBMS' 카테고리의 다른 글
[Oracle] ORA-00054 : resource busy and acquire with nowait specified or timeout expired (0) | 2022.03.25 |
---|---|
[Oracle, Sqlplus] Oracle11g 한글깨짐 해결중... (0) | 2022.03.16 |
[Oracle] 맥 Docker 설치 후 오라클 연동 (0) | 2022.02.24 |
[Oracle] SQL Joins (INNER, FULL, LEFT, RIGHT, SELF) (0) | 2021.12.26 |
[Oracle] SELECT * FROM +(WHERE,GROUP,ORDER) (0) | 2021.12.26 |