← Homepage

🗄️ SQL (Advanced)

Author: Daniel Jordan Viray

COALESCE and NULLIF

Tame NULLs and placeholder zeros: defaults for display, honest averages, and division without the divide-by-zero.

CTEs and Subqueries

Same question, two shapes: name your intermediate steps with WITH, or nest them inline. Readability is the difference.

Date Spines and CROSS JOINs

No row for quiet days? Build a calendar spine, cross it with your categories, and LEFT JOIN the events on — zeros included.

EXISTS vs IN / NOT IN

Three ways to ask ‘who has a matching row?’ — plus the NULL trap that makes NOT IN silently return nothing.

Window Functions

ROW_NUMBER, RANK, LAG/LEAD, rolling averages and running totals — per patient, per category — without collapsing rows.

No topics match that filter.