Sql practice 22.2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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"

23rd Apr 2021, 9:24 AM
Chaitanya Joshi
Chaitanya Joshi - avatar
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 :)
26th May 2021, 1:49 AM
Devan Hall
Devan Hall - avatar
+ 1
Hello. Some similar to: Update employees set salary=salary*1.2 where rating > 5
23rd Apr 2021, 11:06 AM
Luis Fabricio Tano
Luis Fabricio Tano - avatar