Give a raise to employees of departments in one city
EasyP3Coding
Tables:
department(id int primary key, city text)
employee(id int primary key, salary int, department_id int)
Write an UPDATE that raises the salary of every employee who works in a department located in 'Berlin' by 10 percent, rounded down (integer arithmetic: salary + salary / 10). Other employees, including those without a department, stay unchanged.
The result is checked by reading id, salary from employee ordered by id.
Schema
CREATE TABLE department ( id int PRIMARY KEY, city text NOT NULL ); CREATE TABLE employee ( id int PRIMARY KEY, salary int NOT NULL, department_id int );
Example 1
- Input
- department: (1, Berlin), (2, Pune); employee: (1, 100, 1), (2, 100, 2)
- Output
- (1, 110), (2, 100)
Example 2
- Input
- employee: (1, 105, 1) in Berlin
- Output
- (1, 115)
- Why
- 105 / 10 is 10 in integer division.
Constraints
- PostgreSQL dialect.
- Write one UPDATE statement; do not select.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
PostgreSQL
Run checks the 3 visible tests, Submit all 5. ⌘Enter runs, ⌘⇧Enter submits.