Skip to the content

Starting at the bottom

Problem

Management approved a raise of 150 a month and wants to start at the bottom: it goes to whoever earns the least in each department. If two people share their department's lowest salary, both get it. In a department of one, that one person is the lowest paid.

Carol has no department, and her salary stays as it is.

Write the change. It's graded by looking at every salary in the company afterward, so it can't give anyone a raise they weren't due.

What it has to return

After your code, this query runs

SELECT id, name, salary FROM employees;

These rows, in any order

idnamesalary
1Carol5200
2Mark3800
3Paige4100
4Rachel2050
5Nicole2100
6Samuel3000
7Lydia3000
8Frank2750
9Grace2550

This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.

You start with this

SQL

UPDATE employees
SET salary = salary + 150
WHERE salary = (
  SELECT MIN(salary)
  FROM employees
);
Solve this challenge

It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.

More O(n²) challenges

See all challenges →