출처: https://astrocosmos.tistory.com/202 [ASTROCOSMOS:티스토리] SQL 이론] ORDER BY, WHERE :: 하나둘셋넷
728x90

SQL 이론] ORDER BY, WHERE

 

정렬 X

SELECT * FROM TABLE1;

 

오름차순

SELECT * FROM TABLE1 ORDER BY COLUMN1 ASC;

 

오름차순 ASC 생략

SELECT * FROM TABLE1 ORDER BY COLUMN1;

 

내림차순

SELECT * FROM TABLE1 ORDER BY COLUMN1 DESC;

 

여러 컬럼 기준

SELECT * FROM TABLE1 ORDER BY COLUMN1 ASC, COLUMN2 ASC;

 

조건식 적용

SELECT * FROM TABLE1 WHERE CONDITION1 ORDER BY COLUMN1

 

컬럼 번호로 정렬

SELECT * FROM TABLE1 WHERE CONDITION1 ORDER BY 1 DESC, 2 ASC

 

728x90

+ Recent posts