Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Construct SQL queries using Oracle for the following questions. 1)How many different departments are there? 2) What is the average salary of professors in each

Construct SQL queries using Oracle for the following questions.

1)How many different departments are there?

2) What is the average salary of professors in each department?

3) List the courses (courseid and coursename) along with the teacher (teachername) teaching it.

4) List the number of courses (how many) taught by each department.

image text in transcribed

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 03

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions