skip to today's puzzle
SQL Sip

COALESCE replaces a NULL with a fallback value

When a cell holds NULL, you often want to show something friendlier than nothing. COALESCE reads its values left to right and returns the first one that is not NULL. So if a student's nickname is NULL, it falls back to their name instead.

A tiny example

In plain English: Show me each student's nickname, or their name when there is no nickname.

SELECT COALESCE(nickname, name) AS label
FROM students;

What comes back

label
Mimi
Otto

Mia has the nickname Mimi, so that wins; Otto's nickname is NULL, so it fell back to Otto.

Related SQL lessons

Ready for a break?

Take on today's cozy puzzle. A fresh, bite-sized query waits every morning — no timers, no pressure.

play today's sip