본문 바로가기

PostgreSQL

PostgreSQL | ORDER BY 오름차순 내림차순

데이터를 오름차순이나 내림차순으로 뽑아낼때 쓴다

 

1. 오름차순(기본값은 ascending)

SELECT * FROM tablename ORDER BY column_name;

SELECT * FROM tablename ORDER BY column_name ASC;

 

2. 내림차순(descending)

SELECT * FROM tablename ORDER BY column_name DESC;