01 / 05
Narrowing by an aggregated number
You can get a total per stall. So how do you write "only the stalls whose total is 18 or more"?
You will want to put it in WHERE, but that is not allowed. At the moment WHERE works, no total has been worked out yet.
SELECT stall, SUM(sold) FROM sales WHERE SUM(sold) >= 18 GROUP BY stall;Result
error: misuse of aggregate: SUM()