Practice by topic · 10 drills
NULLs & CASE
IS NULL, COALESCE, NULLIF and CASE WHEN: the logic that trips people up. Ordered easiest first.
Read the guide first: NULL in SQL: IS NULL, COALESCE and the mistakes NULL causesStart: Salary bands 0/10 solved
- 1. Salary bandsCASE WHEN · SQL BasicsUp next
- 2. Filling in missing managersNULL · COALESCE · SQL BasicsFree
- 3. Users who never subscribedLEFT JOIN · IS NULL · Joining TablesFree
- 4. Spend by category, one row per accountPivot with FILTER / CASE · CTEs & Reshaping DataPro
- 5. Wallet balance from a ledgerSUM(CASE) · signed amounts · LEFT JOIN + COALESCE · Interview ClassicsPro
- 6. Missing values per sourceCOUNT(*) - COUNT(col) · data quality · Database AnalystPro
- 7. Orphaned invoicesNOT EXISTS · orphan rows · NOT IN and NULL · Database AnalystPro
- 8. Payments that break the rulesValidation rules · OR · NULL-safe checks · Database AnalystPro
- 9. Parse a text-only importTRIM · NULLIF · regexp_replace · ::numeric · ::date · Database AnalystPro
- 10. Rows that would block a constraintUNIQUE · CHECK · NULL semantics · UNION · Database AnalystPro