Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views2 pages

AP2024254000878 Experiment-2

The document outlines an SQL assignment involving two tables: Employees and Departments. It provides specific tasks requiring various types of SQL joins, including INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN, SELF JOIN, CARTESIAN JOIN, UNION, and INTERSECTION. Each task includes a brief description of the expected output for the SQL queries to be written.

Uploaded by

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

AP2024254000878 Experiment-2

The document outlines an SQL assignment involving two tables: Employees and Departments. It provides specific tasks requiring various types of SQL joins, including INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN, SELF JOIN, CARTESIAN JOIN, UNION, and INTERSECTION. Each task includes a brief description of the expected output for the SQL queries to be written.

Uploaded by

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

SQL Joins Assignment

Instructions:

Use the given Employees and Departments tables to write SQL queries for the following
tasks.

Employees Table

EmployeeID Name DepartmentID Salary


1 Alice 101 60000
2 Bob 102 55000
3 Charlie 103 70000
4 David 101 65000
5 Emma NULL 50000

Departments Table

DepartmentID DepartmentName
101 HR
102 IT
103 Finance
104 Marketing

Questions:

1. INNER JOIN
Write an SQL query to retrieve employee names and their department names. Include
only employees who are assigned to a department.
2. LEFT JOIN
Write an SQL query to return all employees along with their department names.
Include employees even if they do not belong to a department.
3. RIGHT JOIN
Write an SQL query to return all departments and their employees, including
departments that do not have employees.
4. FULL JOIN
Write an SQL query to return all employees and departments, even if there is no
match between them.
5. SELF JOIN
Assume the Employees table contains a ManagerID column that references
EmployeeID. Write an SQL query to list employees along with their managers' names.
6. CARTESIAN JOIN
Write an SQL query that returns all possible employee and department combinations,
even if they are not related.
7. UNION
Write an SQL query to return a list of all employees and departments from both
Employees and Departments tables (without duplicates).
8. INTERSECTION (Common Employees in Multiple Queries)
Write an SQL query to return employees who appear in both:
 A list of employees earning more than 55000
 A list of employees working in IT or Finance departments

You might also like