Exercise · SQL & Querying
Predict, then run it
Predict the output
mat(part, cost) = (beam,40),(rope,5),(beam,40). Restructure the copy-pasted totals into one CTE with two consumers:
WITH totals AS (SELECT part, SUM(cost) AS c FROM mat GROUP BY part) SELECT (SELECT c FROM totals WHERE part='beam') AS beams, (SELECT c FROM totals WHERE part='rope') AS ropes;
Predict the exact output.