Separate row eligibility from aggregate thresholds in a basic inventory query.
The carts are ready, but the low-stock rule must land in the right clause. What should Mateo do in the query? Filter current counts and active SKUs in WHERE, group by aisle, then use HAVING SUM(units) < 40. Right. WHERE defines eligible shelf rows before aggregation; HAVING filters the aisle groups after SUM exists. Put SUM(units) < 40 in WHERE because low stock is the most important filter. Weaker. SUM is not available until after GROUP BY, so this violates the query pipeline and confuses row filters with group filters. Filter shelf rows where units < 40, then group by…
Sign up free: one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in