You are on page 1of 2

CNC314 DATABASE Fall 23.

24
QUIZ (Model A)

1. Complete the code.


The HR department needs a list of department IDs for departments
that do not contain the job ID ST_CLERK. Use the set operators to
create this report.
SELECT department_id
FROM departments
……………….
…………………………………………………………………………

ANS:
Minus
SELECT department_id FROM employees WHERE job_id = 'ST_CLERK';

2. Create a query to display the employee numbers and last names


of all employees who earn more than the total salary. (using subquery)
ANS:
SELECT employee_id, last_name
FROM employees
WHERE salary > (SELECT SUM(salary)
FROM employees);

3. Write a query to display the following for those employees whose


manager ID is less than 120:
– Manager ID
– Job and total salaries for every job for employees who report to
the same manager
– Total salary of those managers
– Cross-tabulation values to display the total salary for every job,
irrespective of the
manager
CNC314 DATABASE Fall 23.24
QUIZ (Model A)
– Total salary irrespective of all job titles
ANS:
SELECT manager_id, job_id, sum(salary)
FROM employees
WHERE manager_id < 120
GROUP BY CUBE(manager_id, job_id);

You might also like