Write the SQL queries for the following. 5.3 Get the names of all workers in the
ID: 3813590 • Letter: W
Question
Write the SQL queries for the following.
5.3 Get the names of all workers in the Accounting department
5.7 Get the names and departments of all workers on project 1019.
5.15. Find the employee names and department manager names of all workers who are not assigned to any project.
5.17 Get a list of project numbers and names and starting dates of all projects that have the same starting date.
Dept CdeptName mgrIdO Worker Cempld, empName ,dateHired,birthdate,salary, deptName) Project projNo, projName startDate, budget expectedDuration, projMgrld) Assign CempId proiNo, hours rating)Explanation / Answer
5.3 Get the names of all workers in the Accounting department
select empName from worker inner join Dept on Dept.deptName = Worker.deptName where dept.deptName = 'Accounting';
5.7 Get the names and departments of all workers on project 1019.
select w.emp_name d.deptName from Worker w, Assign a , Dept d where a.projNo = 1019 and W.empid = a.empid;
5.15. Find the employee names and department manager names of all workers who are not assigned to any project.
select (select empname from worker where empid in (select empid from employees where empid not in (select distinct empid from assign)),
select mgrid from dept where deptname in (select deptname from worker where empid in (select empid from employees where empid not in (select distinct empid from assign)))) from dual;
5.17 Get a list of project numbers and names and starting dates of all projects that have the same starting date.
select p1.projNo,p1.projName, p1.startDate from project p1, project p2 where p1.projNo <> p2.projNo and p1.startDate = p2.startDate;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.