0% found this document useful (0 votes)
59 views

SQL Assignment #5. YejiKim

This document provides instructions and examples for an SQL homework assignment involving subqueries. It notes that there are now only 3 questions instead of the original 5. The document provides the full SQL queries for the first two questions as examples, and outlines the requirement for the third question to display employees whose salary is greater than all employees in a specific job role, without providing the full solution. Students are instructed to use the appropriate operator such as >, =, >ANY, <ALL, etc. to solve it.

Uploaded by

Yeji Kim
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

SQL Assignment #5. YejiKim

This document provides instructions and examples for an SQL homework assignment involving subqueries. It notes that there are now only 3 questions instead of the original 5. The document provides the full SQL queries for the first two questions as examples, and outlines the requirement for the third question to display employees whose salary is greater than all employees in a specific job role, without providing the full solution. Students are instructed to use the appropriate operator such as >, =, >ANY, <ALL, etc. to solve it.

Uploaded by

Yeji Kim
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

NOTE: This homework assignment has been changed from the lecture, there

are 2 fewer questions (3 questions total)

BSAN310 SQL Lab #5 Subqueries


NOTE: For all these SQL statements in your answers, you must write SQL
subqueries.
For these subqueries, only use the table hr.employees (thus all FROM clauses are FROM
hr.employees)

1. The HR department needs a query that displays the last name, hire date, and department ID
of any employee in the same department as the employee with the last name of Hall.
SELECT last_name, hire_date, department_id
FROM HR.EMPLOYEES
WHERE department_id =
(SELECT department_id
FROM HR.EMPLOYEES
WHERE last_name = 'Hall');

2. Create a report that displays the employee number, last name, and salary of all employees
who earn more than the average salary of the entire company.
SELECT employee_id, last_name, salary
FROM HR.EMPLOYEES
WHERE salary >
(SELECT AVG(salary)
FROM HR.EMPLOYEES);

4. This is what we went through at the end of class…Create an SQL query (subquery) to display the
first name, last name, and salary of all employees that have a salary that is greater than the salary of all
employees that have the job_id of ST_MAN.

SELECT first_name, last_name, salary


FROM HR.EMPLOYEES
WHERE salary > ALL
(SELECT salary
FROM HR.EMPLOYEES
WHERE job_id = 'ST_MAN');
For this problem, You need to think about what operator (for example >, =,
>ANY, <ALL, >ALL, <ANY, or others) to use in this subquery
See slides 17-24

For your inner query, your SQL statement will be:


(SELECT salary
FROM hr.employees
WHERE job_id =’ST_MAN’)

Now, you need to create the outer query and focus on using the correct operator.

You might also like