Question: So I'm working on SQL homework and I don't know how to write this Query. The question asks to Find the name of managers that

So I'm working on SQL homework and I don't know how to write this Query. The question asks to "Find the name of managers that have their salary smaller than some of the employee they manage". My professor says I should a WITH clause.

Here are the tables I am using:

create table Employee ( Employee_name varchar2(75), Street varchar2(75) not null, City varchar2(50) not null, PRIMARY KEY (Employee_name) );

create table Company ( Company_name varchar2(75), City varchar2(50) not null, PRIMARY KEY (Company_name) );

create table Works ( Employee_name varchar2(75), Company_name varchar2(50) not null, Salary number(25) not null, PRIMARY KEY (Employee_name), FOREIGN KEY (Employee_name) REFERENCES Employee(Employee_name), FOREIGN KEY (Company_name) REFERENCES Company(Company_name) );

create table Manages ( Employee_name varchar2(75), Manager_name varchar(75) not null, PRIMARY KEY (Employee_name), FOREIGN KEY (Employee_name) REFERENCES Employee(Employee_name), FOREIGN KEY (Manager_name) REFERENCES Employee(Employee_name) );

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!