A Brightlane operations manager is verifying the total cost of a bulk order before issuing a purchase order. The order covers 6 bundles. Each bundle is priced at $12 for the item itself plus a $3 per-bundle handling fee.
Write a query to return the total order cost in a single column named total_order_cost.
Output:
- A single row with one column,
total_order_cost, containing the full bundled total.
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
(12 + 3) * 6 AS total_order_cost The shape
The parentheses bundle the per-bundle item cost and the handling fee into a single per-bundle figure, then the multiplication scales that combined cost across six bundles.
Clause by clause
SELECT (12 + 3) * 6runs the parenthesised addition first:12 + 3returns15, the all-in per-bundle cost. The multiplication then scales that across the order quantity and returns90. All three operands are integers, so the result is the integer90— the total in whole dollars, which matches the purchase-order format the operations manager is filling in.AS total_order_costlabels the column as the figure the PO is being issued for. The result reads as a procurement line item rather than a math expression.
Why this and not 12 + 3 * 6
Strip the parentheses and operator precedence reorders the calculation. 3 * 6 resolves first to 18, then 12 + 18 returns 30. That would be the answer to a different question — "one bundle's item cost plus the handling fee applied across six bundles" — and it's wrong for this prompt. Every bundle carries both costs, so both have to scale.
The parentheses are how the prompt's business logic — "each bundle is priced at $12 plus a $3 handling fee" — gets translated into the SQL evaluation order. The shape (component_a + component_b) * quantity recurs any time a per-unit cost is itself a sum: per-seat licence plus support fee, per-shipment freight plus insurance. The grouping has to be explicit, or the multiplication will only catch one of the components.
You practiced grouping a sum inside parentheses before scaling it. The recurring shape: any time a per-unit cost has multiple components and you need to multiply the bundled cost by the unit count, parentheses force the addition to complete first.