Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELP WITH THIS QUERY IN NEEDS TO MATCH THE TABLE THAT BELOW. I will also the query I got but is incorrect. Write a
PLEASE HELP WITH THIS QUERY IN NEEDS TO MATCH THE TABLE THAT BELOW. I will also the query I got but is incorrect.
Write a query to display the managers SSN managers first and last name with a space between them, department number, department name, employees SSN employees first and last name with a space between them, and the following information about the employee's dependents: name, relationship and date of birth. The department number and name are that of the employee, not the manager. Name the columns as follows: Manager SSN Manager Name, Department, Employee SSN Employee Name, Dependent Name, Relationship and Dependent DOB. Sort the results by department number, employee SSN in all ascending order. See sample output below. pts
SELECT CONCATSUBSTRINGmgrempssn SUBSTRINGmgrempssn SUBSTRINGmgrempssn AS "Manager SSN
CONCATmgrempfirstname, mgremplastname AS "Manager Name",
CONCATeempdptnum, ddptname AS Department,
CONCATSUBSTRINGeempssn SUBSTRINGeempssn SUBSTRINGeempssn AS "Employee SSN
CONCATeempfirstname, eemplastname AS "Employee Name",
dpt depname AS "Dependent Name",
dpt deprelationship AS Relationship,
DATEFORMATdptdepdateofbirth, M dY AS "Dependent DOB"
FROM employee e
JOIN department d ON eempdptnum ddptno
JOIN employee mgr ON ddptmgrssn mgrempssn
LEFT JOIN dependent dpt ON eempssn dptdepempssn
ORDER BY eempdptnum ASC, eempssn ASC;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started