반응형

[Oracle SQL] SELECT 실습_ ORDER BY 



I ORDER BY

▶ 정렬(SORTING) : 숫자, 문자, 날짜, NULL(가장 큰 값으로 간주)

▶ ASC   : 오름차순(ASCENDING ORDER), DEFAULT

    DESC : 내림차순(DESCENDING ORDER)



1. ORDER BY



SELECT ENAME,HIREDATE FROM EMP ORDER BY ENAME;






SELECT ENAME,HIREDATE FROM EMP ORDER BY ENAME DESC;





2. ORDER BY 추가


2번째 COLUMN으로 정렬


SELECT ENAME,SAL,HIREDATE FROM EMP ORDER BY 2;




별칭으로 정렬


SELECT ENAME,SAL*12 AS ANNUAL_SAL FROM EMP ORDER BY ANNUAL_SAL;





선택하지 않은 COLUMN 기준으로 정렬


SELECT EMPNO,ENAME,COMM,JOB FROM EMP ORDER BY SAL;



반응형