▸_sqlgym

12. Sort With NULLs Last

MediumOrderingNULL orderingexpression sort key

In SQLite NULLs sort first by default. To push them to the bottom you sort on a boolean expression that is 0 for real values and 1 for NULL before the real sort key.

Task: return name and last_seen from contacts, ordered by last_seen descending, but with contacts who have never been seen (last_seen IS NULL) at the very bottom.

Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…

This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases 5test cases in all. A sloppy query that only fits the example won't pass.

SQL
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.