Question: Assignment: SQL Operations Practice Objective: The objective of this assignment is to help students understand and apply SQL concepts such as table creation, UNION, INTERSECT,
Assignment: SQL Operations Practice
Objective:
The objective of this assignment is to help students understand and apply SQL concepts such as table creation, UNION, INTERSECT, WHERE, AND, OR NOT, and other set operations without using JOIN.
Dataset:
Students need to create two tables: Employees and Departments.
Step : Create Tables
Create the following two tables:
Table: Employees
CREATE TABLE Employees
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR
LastName VARCHAR
DepartmentID INT,
Salary DECIMAL
HireDate DATE,
JobTitle VARCHAR
;
Table: Departments
CREATE TABLE Departments
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR
Location VARCHAR
;
Step : Insert Sample Data
Insert sample data into these tables. You can use your own sample data or refer to the following:
Employees: Insert records.
Departments: Insert records.
Step : Solve the Problems
Problems:
List all employees who have a salary greater than $
o Hint: Use the WHERE clause to filter employees with a salary greater than $
Display employees who work in the IT department and earn less than $
o Hint: Use the AND operator to apply multiple conditions.
Find all employees who are either 'Managers' or 'Analysts'.
o Hint: Use the OR operator to include multiple job titles.
List all employees who do NOT work in the HR department.
o Hint: Use the NOT operator along with the WHERE clause.
Create a query using UNION to combine results of employees in the 'Finance' department and those who are 'Analysts'.
o Hint: Use two separate queries combined with UNION to merge results.
Use INTERSECT to find employees who have the job title 'Developer' and are also in the IT department.
o Hint: Use two queries and the INTERSECT operator to identify common records.
Create a query using EXCEPT or MINUS for Oracle to find employees in the 'Finance' department who are not 'Managers'.
o Hint: Use EXCEPT or MINUS to subtract 'Manager' employees from 'Finance' department employees.
Find all employees hired after January and earning a salary between $ and $
o Hint: Use the WHERE clause with the BETWEEN operator and a date condition.
List employees who have a department ID of or
o Hint: Use the IN operator to filter by multiple department IDs.
Find employees whose last names do not start with the letter A
o Hint: Use the NOT LIKE operator with a wildcard to exclude specific names.
Submission Guidelines:
For each problem, write the SQL code and provide screenshots or outputs of the results.
Ensure your code is welldocumented with comments to explain the logic of each query.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
