Learn with Abdou

INTERACTIVE LECTURES

CASE & UNION: one report, many sources

Guided class activity · apply the ideas from the full SQL lessons.

Preparing for Lab 9 · After practice, try the team challenge.

Opening your saved work…

Sign in to save across devices → · Download your guest work before switching accounts.

Keep unknown ratings separate from low ratings

Step 2 of 8 · Database: Boreal Board Game Café

READ & UNDERSTAND

A missing rating is not a zero-star review. Comparing NULL to a number produces an unknown result, so it does not select a WHEN branch. Without an explicit IS NULL branch, the row reaches ELSE.

For a review queue, use Awaiting review for NULL, Recommend for ratings at least 4.4, and Review notes for the remaining ratings. These labels describe this practice queue, not the official shelf-label question. Test both new arrivals and a known low-rated game.

Different columns give NULL different meanings: games.rating is not yet rated, sessions.score is absent for cooperative play, members.phone is not on file, and cafe_orders.member_id marks a walk-in. COALESCE can provide a display label, but replacing all of these with zero would erase their meanings.

Worked example
SELECT id, title, rating, CASE WHEN rating IS NULL THEN 'Awaiting review' WHEN rating >= 4.4 THEN 'Recommend' ELSE 'Review notes' END AS review_state FROM games WHERE id >= 10 ORDER BY id;

The sample includes both missing ratings and known values. IS NULL catches a missing rating explicitly.

The full queue should contain all 14 games. An unknown value is classified, not dropped.

Your question

Return id, title and review_state for all games using the three review-queue rules above, ordered by id.

Explain your evidence

Would COALESCE(rating, 0) preserve the meaning of a rating? Show the two kinds of evidence it would combine.

Try a query to unlock the worked-answer discussion.

Loading…
Table & column names only · ↑ ↓ choose · Tab insert · Esc dismiss

CURRENT DATABASE

Quick schema · Boreal Board Game Café

Press Esc or click outside to return to your query. PK = primary key · FK = declared foreign key.

This database has no tables yet. Create a table, then reopen the schema to see its columns.

Control Space also opens names. Enter adds a new line. Control or Command Enter runs your query.

Query results

Predict the result, then run your query.

Predict the result, then run your query.

Read-only activity · One statement per run · First 200 rows displayed · Checks compare the complete bounded result, not just this preview.

Explore this query freely in the playground ↗

Check the save status above. Account-saved work is available in My Progress. Explanations are for discussion, not automatically graded. No prerequisite locks.