A marketing manager at Brightlane is calculating the total cost for a quarterly campaign. The campaign runs for 3 months, and each month's spend is a $400 advertising budget plus a $150 content production fee.
Write a query to return the total campaign cost in a single column named campaign_cost.
Output:
- A single row with one column,
campaign_cost, containing the full quarterly total.
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
(400 + 150) * 3 AS campaign_cost The shape
The parentheses force the per-month components to add up first, and then the three-month quarter scales the combined monthly spend. Without them, only the content fee would scale across the quarter.
Clause by clause
SELECT (400 + 150) * 3runs the parenthesised addition first:400 + 150returns550, the full per-month spend. The multiplication then scales that monthly figure across the three-month quarter and returns1650. All three operands are integers, so the result is the integer1650.AS campaign_costlabels the column as the quarterly total. The marketing manager can hand the result to finance with the column already named in the language of the budget.
Why this and not 400 + 150 * 3
Strip the parentheses and operator precedence runs the multiplication first. 150 * 3 resolves to 450, and the addition produces 850. That would be the answer if only the content piece recurred each month and the ad budget were a one-time flat fee. The prompt says both are monthly, so both have to scale, and the parentheses are what tell SQL to treat the sum as the thing being scaled.
You practiced overriding default operator precedence with parentheses. Without them, 400 + 150 * 3 would evaluate the multiplication first and produce the wrong total — (400 + 150) * 3 forces the addition to complete before the scaling.