SELECT Statements SQL Topic exerciseMediumVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

Calculate Monthly Salary

Return each employee’s annual salary and calculated monthly salary.

  • Numeric functions

Exercise brief

Understand the request

Compensation systems analyst A monthly payroll preview needs annual salary converted to a comparable monthly amount without losing cents.

Convert each employee’s annual salary into a monthly amount and label the calculated column monthly_salary.

Return

  • Return first_name, salary, and monthly_salary in this exact left-to-right order.
  • Calculate monthly_salary as salary divided by 12 and round it to 2 decimal places.

Constraints

  • Keep one row per employee.
  • Use decimal division so salaries that are not divisible by 12 retain cents.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

employees

  • first_nameVARCHAR(50)
  • salaryINTEGER

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Monthly pay is the annual salary distributed across 12 months.

Hint 2

Use decimal division rather than integer division, then apply rounding to the calculated value.

Hint 3

Project the two source columns first, followed by one named arithmetic expression.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT first_name, salary, ROUND(salary / 12.0, 2) AS monthly_salary FROM employees;

Why this works

Using 12.0 makes the division decimal across the supported engines, while ROUND(..., 2) gives the export a stable currency precision. The calculation combines values with compatible compensation semantics.

Success check

Every employee appears once and monthly_salary equals annual salary divided by 12, rounded to 2 decimal places.

Expected result

Use this output to verify values, aliases, ordering, and row count.

first_namesalarymonthly_salary
John12000010000
Alice850007083.33
Bob800006666.67
Carol600005000
David700005833.33
Emma950007916.67
Frank650005416.67
Grace900007500
Henry550004583.33
Ivy680005666.67

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.