Exercise · SQL & Querying
Predict, then run it
Predict the output
cs(scent, month, n) = (rose,Jan,5),(rose,Feb,3),(pine,Jan,2). Pivot to a scent × month grid; pine never sold in Feb, and that cell must read 0:
SELECT scent, SUM(CASE WHEN month='Jan' THEN n ELSE 0 END) AS jan, SUM(CASE WHEN month='Feb' THEN n ELSE 0 END) AS feb FROM cs GROUP BY scent ORDER BY scent;
Predict the exact output.