For the Following Relation Schema
For the Following Relation Schema
1. Find the names, street address, and cities of residence for all employees who work for 'First Bank
Corporation' and earn more than $10,000.
2. Find the names of all employees in the database who live in the same cities as the companies for
which they work.
3. Find the names of all employees in the database who live in the same cities and on the same
streets as do their managers.
4. Find the names of all employees in the database who do not work for 'First Bank Corporation‘
5. Find the names of all employees in the database who earn more than every employee of 'Small
Bank Corporation'. Assume that all people work for at most one company.
6. Assume that the companies may be located in several cities. Find all companies located in every city in
which 'Small Bank Corporation' is located
7. Find the names of all employees who earn more than the average salary of all employees of their
company. Assume that all people work for at most one company.
8. Find the name of the company that has the smallest payroll.
Answers
4. select employee-name from works where company-name <> 'First Bank Corporation'
5. select employee-name from works where salary > all (select salary from works where company-name
= 'Small Bank Corporation')
6. select s.company-name from company s where not exists ((select city from company where company-
name = 'Small Bank Corporation') except (select city from company t where s.company-name =
t.company-name))
7. select employee-name from works t where salary >(select avg(salary) from works s where t.company-
name = s.company-name)
8. select company-name from works group by company-name having sum(salary) <= all (select
sum(salary) from works group by company-name)
3. List the average order amount where "for the current year“
5. List the customer names who have not ordered for item no. 10.