+ 2
Sql practice 22.2
Please assist to write query for Practice 22.2 of sql "Write a query to increase salaries by 20% for those employees whose rating is above 5. Then show the updated table"
2 Answers
+ 2
So weâre using the UPDATE and SET keywords for this problem. We want to update the âcompanyâ table with a 20% increase to the employees whoâs rating is > 5.
SoâŠ. We can doâŠ
UPDATE company
SET salary = (salary + (salary * .20)
WHERE rating > 5;
SELECT * FROM company
We set the new value of salary equal to the current value of salary * 20% (.20.) Then, using the WHERE keyword, we specify that we only want our function to affect those with a rating greater than 5.
Finally, we close off that statement with a semi-colon, and proceed with our SELECT * FROM company statement so that it actually shows the table.
Hope this helps :)
+ 1
Hello. Some similar to: Update employees set salary=salary*1.2 where rating > 5