INTERACTIVE LECTURES
Summarize and compare
Guided class activity · apply the ideas from the full SQL lessons.
Open the detailed lessons for this activity
Detailed lessons in this module
Open the full explanations, examples, and SQL exercises directly.
Opening your saved work…
Sign in to save across devices → · Download your guest work before switching accounts.
Count rows and known values
Step 1 of 4 · Database: Northshore Coffee
READ & UNDERSTAND
COUNT(*) counts rows. COUNT(calories) counts rows with a non-NULL calorie value. COUNT(DISTINCT category) counts different known categories. Always say what is being counted.
NULL means a value is missing or unknown; it is not automatically zero. AVG ignores NULL values, so an average may describe only part of the menu. State the denominator alongside your conclusion.
Worked example
SELECT COUNT(*) AS items, COUNT(calories) AS known_calories FROM menu_items;
Both aggregates consume the same menu_items rows, but COUNT(calories) ignores rows where that value is NULL. Subtracting known_calories from items reveals how many rows lack that field.
This returns one summary row because there is no GROUP BY. Neither number measures the number of categories; that requires counting distinct category values.
Your question
Return COUNT(*) AS item_count and COUNT(DISTINCT category) AS category_count from menu_items.
Explain your evidence
Why are item_count and category_count answering different questions?
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.