Helix Systems' sales manager is generating a commission statement for a recently closed deal. The deal was worth $48,000 and the account manager's commission rate is 7.5%.
Write a query to return the deal value, the commission rate as a decimal, and the commission amount in dollars in one row.
Output:
- A single row with three columns, in this order:
deal_value,commission_rate, andcommission_amount.
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
48000 AS deal_value,
0.075 AS commission_rate,
48000 * 0.075 AS commission_amount The shape
A percentage stored as its decimal form (0.075) and used directly as a multiplier — the row exposes the deal value, the rate, and the resulting commission as three labeled columns.
Clause by clause
48000 AS deal_valueis a labeled integer literal. The deal closed at $48,000 in revenue, and the alias names the column so the row reads in commission-statement form, with each number labeled by its role.0.075 AS commission_rateis the rate expressed as a decimal: 7.5% written as the number SQL can multiply by. SQL only knows the decimal form.48000 * 0.075 AS commission_amountis the multiplication: an integer times a decimal, producing3600.000. The trailing zeroes are the scale PostgreSQL chose by combining the input scales — integer = 0 decimal places,0.075= 3 decimal places, so the result carries 3. The dollar value is still $3,600; the extra zeroes carry precision through the operation rather than indicating any rounding.
Why decimal form and not the percentage notation
SQL has no % operator. A rate written as 7.5% is not something the engine can multiply by — there's no syntax for it. So percentages live in queries as their decimal form: 7.5% becomes 0.075, 25% becomes 0.25, and so on. The conversion is just "drop two decimal places."
The same form works in either direction. If a question gives you a decimal rate and asks for the percentage, you multiply by 100. If it gives you a percentage and asks for the resulting amount, you divide the percentage by 100 to get the decimal, then multiply. The decimal is the form SQL works in.
You practiced expressing a percentage as its decimal form (0.075) and using it to scale another value. Decimal-rate-times-quantity is the recurring shape for every percentage calculation in SQL.