A payroll analyst is verifying a compensation record before submitting it to the finance system. The annual salary on file is $2,400.
Write a query to return the annual salary and the monthly equivalent in a single row, with the columns named annual_salary and monthly_salary.
Output:
- A single row with two columns:
annual_salary(the annual figure) andmonthly_salary(annual divided by 12).
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
2400 AS annual_salary,
2400 / 12 AS monthly_salary The shape
Two comma-separated expressions in the SELECT list produce two labeled columns in a single row — the annual figure straight from the file, the monthly figure derived from it.
Clause by clause
2400 AS annual_salaryis a labeled integer literal. The annual salary on file is2400, and the alias names the column so the row reads in payroll-record form rather than as anonymous numbers.2400 / 12 AS monthly_salaryis the derived figure: the annual salary divided into twelve equal pieces. Both operands are integers, and2400is evenly divisible by12, so the result is the integer200— no decimal needed, the math lands clean.- The comma between the two expressions is what makes them sit in the same row. Each expression evaluates independently, and the row that comes back has one column per expression, in source order. Each alias only labels its own column; the names don't carry meaning across the comma.
Why this and not one expression
The annual and monthly figures could each live in their own one-column query, run twice. The comma-separated form returns both in one round trip, in the exact order the payroll record expects, with the headers set inline. That's the recurring shape: one SELECT, many aliases, one row that already reads as the output format.
You practiced aliasing more than one expression in a single SELECT. Each item in the SELECT list carries its own alias — the recurring shape any time a query produces several derived columns that all need clear names.