You are on page 1of 5

Q1.

Retrieve the Emp_id, name of all the employees assigned to a task in any project of
customer Naman.

SELECT DISTINCT e1.emp_id, e1.fname, e1.lname FROM ((((Employee e1


JOIN assignment a ON e1.emp_id = a.emp_id ) schema
JOIN task t ON a.task = t.tid )
JOIN projects p ON t.proj = p.pid)
JOIN customer c ON p.customer_id = c.cus_id)
WHERE c.cus_name = 'Naman';
Write a query to retrieve the name of all the employees who completed their assignment
yesterday but didn't filed the worklog till date.
Select emp_id, fname, lname
from Employee e join assignment a on e.Emp_id = a.Emp_id schema
where (end_d=GETDATE()-1) and
not exists(select * from worklog w
where w.emp_id=e.emp_id and filedate>=GETDATE()-1);
For each task that has more than 1 employee currently assigned to it, retrieve the
assignment numbers,employee id and emp names(fname) working on it .
select ass_id,a.emp_id,fname
from employee e join assignment a on a.emp_id=e.emp_id schema
where task in(
select task
from assignment
where emp_id is not null
Group by task
having count(emp_id)>1)
Retrieve the name of the employees who possess all the skills required for taskid = ‘1102’

SELECT FNAME, LNAME FROM employee e


WHERE NOT EXISTS((SELECT sk_id from skillxtask st where st.tsid = 1102) schema

MINUS(select skill from empxskill es where es.empid = e.emp_id));


Retrieve the name and emp_id of all the managers who are managing
projects whose estimated budget and actual budget difference is more than
$500
select e1.emp_id,e1.fname schema

from ((Employee e1 join Manager m on e1.emp_id=m.mno) join


Projects p on m.mno=p.manager_id)
where (p.e_budg-p.a_budg)>500;

You might also like