Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SQL Given two tables below with 'Dept' of Employee indicating the department an employee belongs to. If Dept is NULL, the employee either does not

SQL

Given two tables below with 'Dept' of Employee indicating the department an employee belongs to. If Dept is NULL, the employee either does not belong to any department or his belonging department is unknown.

image text in transcribed

Which employee(s) belongs to a department that doesn't exist in Department table? Display his/her EmpID, Dept, and Gender. If the output contains more than one employee, they should be sorted by their EmpID in ascending order.

This query can be solved in many different ways, including (1) ~ (6) described below. Do not include hard coded data values such as 'Sales' and 'E219' in the solution statement.

(1) By a SELECT statement with a regular non-correlated subquery and no table joins, no set operators. (2) By a SELECT statement with a correlated subquery and keyword EXISTS but no table joins, no set operators. (3) By a SELECT statement which uses a CTE [all_dept] with a regular non-correlated subquery but no table joins, no set operators. [all_dept] is defined by "select Dname from Department". (4) Same as (3) but the CTE is used in a table join. No subqueries and no set operators are used in the SELECT statement. (5) By a SELECT statement with a table join and no subqueries, no set operators. (6) By a SELECT statement with set operators but no table joins, no subqueries.

DepartmentI Employee Dname Office EmpID Dept Gender K-71E003 Sales M-22 E012 HR R&D Sales Shipping M-23E354 NULL IT K-71E066 Sals E219 IT E008 Services M

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What reactive strategies might you develop?

Answered: 1 week ago

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago