One raise, not two
- O(n²) · Very hard
- Full plan
- SQL
- changing data
- conditionals
Problem
This year's raise goes by bracket, and the bracket goes by monthly salary: 10% for anyone who earns less than 2500, and 5% for anyone who earns 2500 or more but less than 3500. From 3500 up there's no raise, so Carol and the managers stay where they are.
What sets the bracket is today's salary, the one from before anything gets touched, and nobody gets both raises.
Write the change. Every salary ends in 00, so no raise leaves decimals. It's graded by looking at where every salary in the company ends up.
What it has to return
After your code, this query runs
SELECT id, name, salary FROM employees;These rows, in any order
| id | name | salary |
|---|---|---|
| 1 | Carol | 5200 |
| 2 | Mark | 3800 |
| 3 | Paige | 4100 |
| 4 | Rachel | 2090 |
| 5 | Nicole | 2310 |
| 6 | Samuel | 3150 |
| 7 | Lydia | 3150 |
| 8 | Frank | 2730 |
| 9 | Grace | 2640 |
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 * 1.1
WHERE salary < 2500;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.