Update the salaries of faculty as their current salary + 10000 · (the number of
ID: 3593313 • Letter: U
Question
Update the salaries of faculty as their current salary + 10000 · (the number of courses they are teaching).
Explanation / Answer
As per your requirement, you want to give the increment to specific faculty as per the number of subject he or she taught-
in the above schenario the james with instructor is=1 taugh two subject(Algorithm & Math finance 1) so according to query it increment like salary=salary+10000*2
other three faculties teach one subject so salary=salary+10000*1
and paul does not teach any subject so there is no increment to paul
Query is look like this:
update faculty f set salary=salary+1000*(select count(instructorid) from course c where f.instructorid=c.instructorid);
Step1: first we need to find the no. of subject is taught by any faculty for this we used sub query and used count function for instructorid column
Step2:now we count the number of subject for every faculty on the behalf of instructorid matching
Step3:now update the salary on behalf matching count.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.