Tsallaka zuwa abun ciki
Justice Tech School

Sorting and NULL

NULLs sort first in SQLite ascending. Use CASE or NULLS LAST to control it.

Example
SELECT name, score FROM students ORDER BY score IS NULL, score DESC;

Result

name    | score
Ada     | 92
Zainab  | 88
Amina   | 85
Kofi    | 78
Tunde   | 71
Wanjiru | 64
Sipho   | 59
Esi     | NULL

Exercise

Put NULLs last.

ORDER BY score IS , score

Quiz Test

Which pushes NULLs to the end?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.