COUNT(*), COUNT(x) and COUNT(DISTINCT x) count three different things
The first bug class is the count itself.
Predict
Five orders, two with a promo. What's COUNT(promo)?
Here are two of the counts on the item lines:
SELECT COUNT(*) AS item_lines, COUNT(DISTINCT dish) AS dishesFROM items;
item_lines
dishes
6
5
Six item lines, but pho shows up on two of them, so five different dishes. On orders, the same three counts give five orders, two with a promo, two different codes, and three customers who ordered.
COUNT(*) counts rows.
COUNT(x) counts the rows where x isn't NULL.
COUNT(DISTINCT x) counts the different values of x, leaving NULL out.
In the editor, write FOUR_COUNTS: the step's four counts on orders.
Pick an answer above to see the rest
Instructions
1
Write FOUR_COUNTS: on orders, the rows, the rows with a promo, the different promo codes, and the different customers, as order_rows, with_promo, promo_codes, customers.