[오라클]/SELECT

ORDER BY

broship 2020. 12. 26. 14:03

sort(정렬)
1) 기준(key)
2) 차순(오름차순, 내림차순)

 

SELECT first_name 이름, salary 급여
FROM employees
ORDER BY salary ASC; --asc 생략 가능

SELECT first_name 이름, salary 급여, employee_id id
FROM employees
WHERE employee_id<=110
ORDER BY salary DESC;

--칼럼명으로 정렬
SELECT first_name 이름, salary 급여, employee_id id
FROM employees
ORDER BY salary DESC, employee_id;
--별명으로 정렬
SELECT first_name 이름, salary 급여, employee_id id
FROM employees
ORDER BY 급여 DESC, id;
--순번으로 정렬
SELECT first_name 이름, salary 급여, employee_id id
FROM employees
ORDER BY 2 DESC, 3;
--order by에 계산식 쓰기
SELECT first_name 이름, salary 급여, employee_id id, salary*12 연봉
FROM employees
ORDER BY 급여*12 DESC, 3;

'[오라클] > SELECT' 카테고리의 다른 글

서브쿼리 subquery  (0) 2020.12.27
조인 JOIN  (0) 2020.12.27
다중행 함수(multi row function) 그룹함수  (0) 2020.12.26
단일행 함수(single row function)  (0) 2020.12.26
select  (0) 2020.12.26