0% found this document useful (0 votes)
49 views8 pages

Section 9-3 # 5 5. List The Employees That HAVE Changed Their Jobs at Least Once

This document contains SQL queries and explanations for homework questions. It includes queries to list employees that have changed jobs, find songs and departments that match other records on event_id and location_id, find minimum salaries grouped by department above another department, and use comparison operators like <, IN and > ALL in subqueries.

Uploaded by

Sonia Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views8 pages

Section 9-3 # 5 5. List The Employees That HAVE Changed Their Jobs at Least Once

This document contains SQL queries and explanations for homework questions. It includes queries to list employees that have changed jobs, find songs and departments that match other records on event_id and location_id, find minimum salaries grouped by department above another department, and use comparison operators like <, IN and > ALL in subqueries.

Uploaded by

Sonia Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Harsharan Kaur

Section 9-3
October 31, 2020

Section 9-3 # 5

5. List the employees that HAVE changed their jobs at least once.

SELECT employee_id
FROM employees
INTERSECT
SELECT employee_id
FROM job_history;

Section 10-1 # 3, 10

3. What DJs on Demand d_play_list_items song_id’s have the same event_id as


song_id 45?
SELECT song_id, event_id
FROM d_play_list_items
WHERE event_id IN (SELECT event_id
FROM d_play_list_items
WHERE song_id =45);

10. What are the department names of the Oracle departments that have the same
location ID as Seattle?

SELECT department_name, location_id


FROM departments
WHERE location_id = ( SELECT location_id
FROM locations
WHERE city = 'Seattle');
Section 10-2 # 6

6. Return the department ID and minimum salary of all employees, grouped by


department ID, having a minimum salary greater than the minimum salary of
those employees whose department ID is not equal to 50.

SELECT department_id, MIN(salary)


FROM employees
GROUP BY department_id
HAVING MIN(salary) >
(SELECT MIN(salary)
FROM employees
WHERE department_id <>50);
Section 10-3 # 5 A-D

5. Place the correct multiple-row comparison operators in the outer query WHERE
clause of each of the following:

A. Which CDs in our d_cds collection were produced before “Carpe Diem” was
produced? WHERE year __________ (SELECT year ...

SELECT *
FROM d_cds
WHERE year < (SELECT year
FROM d_cds
WHERE title = 'Carpe Diem');
B. Which employees have salaries lower than any one of the programmers in the
IT department? WHERE salary __________(SELECT salary ...

SELECT department_id, first_name, last_name, salary


FROM employees
WHERE salary < ANY (SELECT salary
FROM employees
WHERE department_id = (SELECT department_id
FROM departments
WHERE department_name = 'IT'));
C. What CD titles were produced in the same year as “Party Music for All
Occasions” or “Carpe Diem”?
WHERE year __________(SELECT year ...

SELECT title, year, cd_number


FROM d_cds
WHERE year IN (SELECT year
FROM d_cds
WHERE title IN ('Carpe Diem', 'Party Music for All Occasions'));
D. What song title has a duration longer than every type code 77 title?

WHERE duration _________(SELECT duration ...

SELECT title, duration


FROM d_songs
WHERE TO_NUMBER(REPLACE(duration, 'min')) >
ALL (SELECT TO_NUMBER(REPLACE(duration,'min'))
FROM d_songs
WHERE type_code = 77);

You might also like