Answer to Question #222384 in Databases | SQL | Oracle | MS Access for Vaishnavi sanjay P

Question #222384
Q.14 Consider the following Schema
course(courseid,title,deptname,credits)
instructor (ID, name, deptname, salary)
1. “Find the average salary of instructors in the Computer Science department.
2. “Find the total number of instructors who teach a DBE course.
3. find the number of tuples in the course relation
4. “Find the average salary in each department.
5. “Find the average salary of all instructors.
1
Expert's answer
2021-08-02T09:08:47-0400


-- 1. “Find the average salary of instructors in the Computer Science department.

SELECT AVG(salary) FROM instructor 
WHERE deptname='Computer Science'

-- 2. “Find the total number of instructors who teach a DBE course.
-- For this query, there should be another table that maintains the relation between instructor and course
-- COnsider below relation exist
-- teaches(ID, course_id, sec_id, semester, year)

SELECT COUNT(distinct ID) FROM teaches where course_id in 
(SELECT courseid FROM course WHERE title='DBE' )

-- 3. find the number of tuples in the course relation


SELECT COUNT(*) FROM course

-- 4. “Find the average salary in each department.


SELECT deptname,AVG(salary) FROM instructor
GROUP BY deptname

-- 5. “Find the average salary of all instructors.

SELECT AVG(salary) FROM instructor 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS