Which SQL query will correctly raise the salary by 10% for employees in the…
2025
Which SQL query will correctly raise the salary by 10% for employees in the 'HR' department who currently earn less than 50,000?
- A.
MODIFY employees SET salary = salary + 10% WHERE department = 'HR' AND salary < 50000;
- B.
UPDATE employees SET salary = salary * 1.10 WHERE department = 'HR' AND salary < 50000;
- C.
UPDATE employees SET salary = salary * 10% WHERE department = 'HR';
- D.
UPDATE employees SET salary = salary + 5000 IF department = 'HR' AND salary < 50000;
Attempted by 99 students.
Show answer & explanation
Correct answer: B
To modify existing records in a relational database, standard SQL uses the UPDATE statement alongside a SET clause to specify the modifications, and a WHERE clause to filter the targeted rows.
To increase a value by 10%, you mathematically multiply the current value by 1.10 (which represents 100% + 10%). The conditions specified in the problem statement require checking two things:
The department must be
'HR'(department = 'HR').The current salary must be strictly less than 50,000 (
salary < 50000).
Combining these requirements yields the standard SQL syntax:
UPDATE employees
SET salary = salary * 1.10
WHERE department = 'HR' AND salary < 50000;