728x90
반응형
ORDER BY
SELECT
select_list
FROM
table_name
ORDER BY
sort_expression1 [ASC | DESC],
...
sort_expressionN [ASC | DESC];
postgresql 에서 Order by절은 select 질의문에서 나온 결과를 정렬 해준다.
dbms에서 데이터가 조회되는 순서 절 아래와 같다
order by 절은 select 실행뒤에 실행되므로 아래와 같은 쿼리도 가능하다.
SELECT
first_name,
LENGTH(first_name) len
FROM
customer
ORDER BY
len DESC;
PostgreSQL ORDER BY clause and NULL
데이터베이스세계에서 NULL 은 누락된 데이터이거나 , 알수없는 데이터를 나타낸다.
postgresql 에서는 null도 order by가 가능하다
ORDER BY sort_expresssion [ASC | DESC] [NULLS FIRST | NULLS LAST]
SELECT num
FROM sort_demo
ORDER BY num NULLS FIRST;
728x90
반응형
'데이터베이스 > postgresql' 카테고리의 다른 글
postgresql - where 절 사용법 (1) | 2024.01.11 |
---|
댓글