PostgreSQL SyntaxLesson 20Free preview
PostgreSQL ORDER BY
This lesson is part of PostgreSQL · All levels
Summary
ORDER BY sorts the query results based on one or more columns, either up or down. The order can be based on columns that aren't even shown, and even based on the column number in the SELECT list. PostgreSQL also sets the position NULL via the NULLS FIRST or NULLS LAST options.
Key points
- ORDER BY sort the results by one or more columns.
- ASC to go up and DESC to go down; default is ASC.
- You can sort out the columns that aren't shown or use the serial number.
- The position can be set with NULLS FIRST or NULLS LAST.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.