Question: Write Sql queries that answer the question below (one nested query per question) in the ANSI-style join. The query answers must not contain duplicates, but

Write Sql queries that answer the question below (one nested query per question) in the ANSI-style join. The query answers must not contain duplicates, but you should use the SQL keyword distinct only when necessary.

1. Retrieve the names of all faculty members who made more than Grace Harper.

2. Find the names of the faculty members whose salary is higher than the average salary of all faculty members.

3. For each department, retrieve the names of the faculty members whose salary is higher than his/her department average salary.

4. Retrieve the ids, names, and addresses of all students who have the same advisor as Alan Turing. Each student has at most one advisor.

5. Retrieve the ids and names o every student who has a major in the same department as Alan Turing. Each student could have more than one major.

 Write Sql queries that answer the question below (one nested query

per question) in the ANSI-style join. The query answers must not contain duplicates, but you should use the SQL keyword distinct only when necessary.

-- defining relations CREATE TABLE Departments ( deptName VARCHAR (30) building VARCHAR (45) budget FLOAT (8,2), PRIMARY KEY (deptName)) 1 CREATE TABLE Faculty CHAR (9), nameVARCHAR (30), office VARCHAR (45), phone CHAR (12), DATE 3sn CHAR (11), email VARCHAR (40) deptName VARCHAR (30) salary FLOAT 10, 2), PRIMARY KEY (id), FOREIGN KEY (deptName) REFERENCES Departments (deptName)) CREATE TABLE Students ( CHAR (9), nameVARCHAR (30), address VARCHAR (45), DATE email VARCHAR (40) advisor CHAR (9), gpa FLOAT (4, 3), PRIMARY KEY (id), FOREIGN KEY (advisor) REFERENCES Faculty (id)); -- defining relations CREATE TABLE Departments ( deptName VARCHAR (30) building VARCHAR (45) budget FLOAT (8,2), PRIMARY KEY (deptName)) 1 CREATE TABLE Faculty CHAR (9), nameVARCHAR (30), office VARCHAR (45), phone CHAR (12), DATE 3sn CHAR (11), email VARCHAR (40) deptName VARCHAR (30) salary FLOAT 10, 2), PRIMARY KEY (id), FOREIGN KEY (deptName) REFERENCES Departments (deptName)) CREATE TABLE Students ( CHAR (9), nameVARCHAR (30), address VARCHAR (45), DATE email VARCHAR (40) advisor CHAR (9), gpa FLOAT (4, 3), PRIMARY KEY (id), FOREIGN KEY (advisor) REFERENCES Faculty (id))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!