Sorting with ORDER BY · ORDER BY를 이용한 정렬
Sorting the result
The rows come back in no particular order. Add ORDER BY to sort them by a column:
ASCsorts ascending (smallest first) — this is the default.DESCsorts descending (largest first).
결과 정렬하기
행은 특정 순서 없이 반환됩니다. 열로 정렬하려면 ORDER BY을 추가하세요:
SELECT name, score FROM student ORDER BY score DESC;
ASC은 오름차순(작은 값부터)으로 정렬합니다 — 기본값입니다.DESC은 내림차순(큰 값부터)으로 정렬합니다.
Sorting by more than one column
Sort text columns alphabetically:
You can sort by several columns: ORDER BY form ASC, score DESC sorts by form first, then by score within each form. ORDER BY always comes last in the query.
여러 열로 정렬하기
텍스트 열을 알파벳 순서로 정렬합니다:
SELECT name FROM student ORDER BY name;
여러 열로 정렬할 수 있습니다: ORDER BY form ASC, score DESC은 먼저 학급으로, 그 후 각 학급 내에서 점수로 정렬합니다. ORDER BY은 쿼리 마지막에 항상 위치합니다.
Common mistakes
- The default sort is ascending; add
DESCfor descending. ORDER BYcomes near the end of the query.
흔한 실수
- 기본 정렬은 오름차순이며, 내림차순으로 변경하려면
DESC을 추가하세요. ORDER BY은 쿼리末尾에 가깝게 배치됩니다.
ORDER BY sorts the rows · ORDER BY는 행을 정렬합니다
ORDER BY puts the result rows in order, like a sort. · ORDER BY는 결과를 정렬된 순서로 배치하여, 마치 정렬하는 것과 같습니다.
Show every student's name and score, highest score first. · 모든 학생의 name과 score을 표시하되, 가장 높은 점수부터 정렬하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Show every student's name, sorted alphabetically (A to Z). · 모든 학생의 name을 표시하되, 영문자 순서(A-Z) 로 정렬하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.