NULLS FIRST and NULLS LAST
ORDER BY options that say whether NULL values sort before or after all other values.
In more detail
The databases disagree by default: SQLite puts NULLs first when sorting ascending and PostgreSQL puts them last. Both accept NULLS FIRST and NULLS LAST, so say which you want whenever a sort column can be empty.
Example
ORDER BY manager_id NULLS LASTRelated terms
- ORDER BY — The clause that sorts a query's answer by one or more columns, each ascending or descending.
- NULL — SQL's marker for a missing or unknown value, which is not zero, not empty text and not equal to anything, even another NULL.
Taught in
- Ordering And Limiting Results — PostgreSQL, Indexing & Relational Data Modeling