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.
Preserve empty events before assigning a label
Step 4 of 8 · Database: Boreal Board Game Café
READ & UNDERSTAND
A report covering every event must start with events and preserve unmatched rows. LEFT JOIN registrations through event_id, then count registrations.id. COUNT(*) would count the placeholder row for an event with no registration.
An aggregate can be the expression a CASE evaluates. In this readiness check, an event is Needs outreach if it has no registrations and Has signups otherwise. Group at event level before applying that rule.
registered_date is the day someone signs up; event_date is the day the event takes place. Likewise, paid records whether a fee is settled. A sign-up count is not attendance, and multiplying signups by fee does not automatically measure received revenue.
Worked example
SELECT e.id, e.name, COUNT(r.id) AS signups FROM events AS e LEFT JOIN registrations AS r ON r.event_id = e.id GROUP BY e.id, e.name ORDER BY e.id;
Each event contributes a row, including the event with no matches.
CASE evaluates the completed count for each group. This is preparation for more detailed event rules in the official lab.
Your question
Return event_id, signups and outreach for all events. outreach is Needs outreach at zero registrations, otherwise Has signups. Order by event_id.
Explain your evidence
Would an INNER JOIN reveal the event most in need of outreach? Why is a registration not proof of attendance?
Try a query to unlock the worked-answer discussion.
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.