Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 1: Write the following queries in SQL : a) Retrieve the names of all em

ID: 3768743 • Letter: E

Question

Exercise 1: Write the following queries in SQL:

a) Retrieve the names of all employees who work in department number 5.

b) Retrieve the supervisor SSNs of all employees who work for the ‘Finance’ department.

c) For every project located in ‘Sharjah’, retrieve the project name, the controlling department name and the department manager’s last name.

d) Retrieve the names of employees who work on all the projects in which the employee with ssn ‘453453453’ is working on.

e) Make a list of the SSN of all employees who are working in department number 4 or employees who are working on projects that are located in Houston.   

Explanation / Answer

Ans a)

// Note For Full Name use Fname,Minit,Lname for print or use Fname only .

Select Fname From Employee Where Dno=5;

Select Fname,Minit,Lname From Employee Where Dno=5;

Ans b)

// No data For Finance Department in Department Table
//Insert data

Ans c)

// There is No data for Sharjah location either insert data then retrieve

Ans d)

select e1.Fname From Employee e1,WORKS_ON w1 where e1.Ssn=w1.Essn;

Ans e)

Select ssn From Employee Where Dno=4;

or

Select e1.Fname From Employee e1,Dept_location d1 where D1.Dnumber=e1.Dno and D1.Dlocation='Houston';