Exercise 7-1 Answer
This is the answer for Exercise 7-1.
Exercises
select distinct dept_id
from employee
where emp_id in
(select emp_id
from benefits
where (vac_accrued - vac_taken) > 80)
and fiscal_year = 1999;
Exercise 7-2 Answer
This is the answer for Exercise 7-2.
select emp_id, num_dependents
from coverage
where num_dependents >
(select avg(num_dependents)
from coverage);
Exercise 7-2b Answer
This is the answer for Exercise 7-2b.
select distinct emp_id, num_dependents
from coverage
where num_dependents >
(select avg(num_dependents)
from coverage);
Exercise 7-3 Answer
This is the answer for Exercise 7-3.
select distinct dept_id
from employee
where exists
(select *
from position
where salary_amount > 50000
and employee.emp_id = "position".emp_id);
Or,
select distinct dept_id
from employee
where exists
(select *
from position p
where salary_amount > 50000
and employee.emp_id = p.emp_id);
Review Answers
These are the answers for Review.
Scenario Answers
These are the answers for Scenarios.
select job_title
from job
where job_id in
(select job_id from position
where salary_amount > 65000);
JOB_TITLE --------- Accountant Appraisal Spec Manager - Acctng Manager - HR Manager - Mktng President Salesperson Sr Mechanic Vice President 9 rows processed
select job_title
from job
where job_id in
(select job_id from position
where salary_amount < 35000);
JOB_TITLE --------- Admin Asst Purch Clerk Sales Trainee 3 rows processed
select dept_id
from department
where not exists
(select *
from employee
where employee.dept_id = department.dept_id)
order by dept_id;
DEPT_ID ------- 4200 4900 6000 3 rows processed
|
Copyright © 2014 CA.
All rights reserved.
|
|