Question
Construct SQL queries using Oracle for the following questions. 1) List the number of courses (how many) taught by each teacher (teacherid is enough no
Construct SQL queries using Oracle for the following questions.
1) List the number of courses (how many) taught by each teacher (teacherid is enough no name needed).
2) Now, list the teacherID, teacherName along with the number of courses taught by each teacher. (Use a Nested SELECT if possbile for this question)
3) List the teacher name, teacher ID, and courses that contain the word Management
4) List all the courses taught by the professors who draw greater than the average salary. Include the courseId, courseName, teahcerID, teacherId, teacherName, salary in your listing.
The code for creating the tables is provided below:
CREATE TABLE r_professors(TeacherID CHAR(2) PRIMARY KEY,
TeacherName VARCHAR2(25),
Salary NUMBER(10,2),
DeptID CHAR(2));
INSERT INTO r_professors VALUES ('11','R',66000,'01'); INSERT INTO r_professors VALUES ('12','Hackbarth',65000,'01');
INSERT INTO r_professors VALUES ('13','Frank Braun',67000,'01');
INSERT INTO r_professors VALUES ('14','John Maddoc',58000,'02');
INSERT INTO r_professors VALUES ('15',' Brandi Neal ',68000,'03');
CREATE TABLE r_courses (CourseID CHAR(6) PRIMARY KEY,
CourseName VARCHAR2(25), TeacherID CHAR(2) REFERENCES r_professors(TeacherID));
INSERT INTO r_courses VALUES ('INF282','Database','11');
INSERT INTO r_courses VALUES ('MBI677',ABAP','11');
INSERT INTO r_courses VALUES ('MBI650','Project Management','12');
INSERT INTO r_courses VALUES ('MBI665','Knowledge Management','13');
INSERT INTO r_courses VALUES ('BUS610','Law and Public Policy','14');
INSERT INTO r_courses VALUES ('BUS330','Ethics','14');
INSERT INTO r_courses VALUES ('INF382','IT Security','13');
INSERT INTO r_courses VALUES ('INF480','Systems Analysis','12');
INSERT INTO r_courses VALUES ('INF420','Web Development','15');
CourseID Course Name Teacher ID 282 Database 11 MB1677 ABAP 11 12 MB1650 Project Management MBI665 Knowledge Management 13 BUS610 Law & Public Policy 14 BUS330 ethics 14 INF382 IT Security 12 INF480 Systems Analysis INF420 Web Development 15 Professors Teacher ID TeacherName Salary DeptID 11 Raghavan 66000 01 12 Hackbarth 65000 01 13 Frank Braun 67000 01 14 John Maddoc 58000 02 15 Brandi Neal 68000 03Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started