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

Problem 2 Using the EMPLOYEE, JOB , and PROJECT tables in the ChO7_ConstructCo d

ID: 3919741 • Letter: P

Question

Problem 2 Using the EMPLOYEE, JOB , and PROJECT tables in the ChO7_ConstructCo database, write the SQL code that will join the JoB EMPLOYEE , and PROJECT tables using common attributes. Display the attributes shown in the results presented in Figure P7.2, sorted by project value. PROJ NAME PROJ VALUE PROJ BALANCE EMP LNAMEEMP FNAME EMP INITIAL JOB CODE JOB DESCRIPTION JOB CHG HOUR Rolling Tide 805000.00500345.20 Evergreen Starflight Amber Wave 3500500.00 2110346.00 Senior Arbough Alonzo Washington Ralph David June Maria 501 500 500 501 Systems Anast 96.75 Programmer Programmer Systems Analyst 96.75 453500.00 1002350.00 35.75 2650500.00 2309880.00 35.75

Explanation / Answer

1.SELECT P.PROJECT_NAME,P.PROJECT_VALUE,P.PROJECT_BALANCE,E.EMPLOYEE_LNAME,E.EMPLOYEE_FNAME,E.EMPLOYEE_INITIAL,J.JOB_CODE,J.JOB_DESCRIPTION,J.JOB_CHG_HOUR FROM EMPLOYEE E,PROJECT P,JOB J WHERE E.EMPLOYEE_ID=J.EMPLOYEE_ID AND P.JOB_CODE=J.JOB_CODE;

In above query i assumed that employee have employee_number and he works for job a job table contains employee_number and job offers project so project contains job_code so using job_code and employee_number we can get the result.

2.SELECT P.PROJECT_NAME,P.PROJECT_VALUE,P.PROJECT_BALANCE,E.EMPLOYEE_LNAME,E.EMPLOYEE_FNAME,E.EMPLOYEE_INITIAL,J.JOB_CODE,J.JOB_DESCRIPTION,J.JOB_CHG_HOUR FROM EMPLOYEE E,PROJECT P,JOB J WHERE E.EMPLOYEE_ID=J.EMPLOYEE_ID AND P.JOB_CODE=J.JOB_CODE ORDER BY E.EMOLOYEE_LNAME DESC;

Generally if we don't mention any order then it defualtly retrieve the values in ascendng order of primary key values.we can use desc for descending by and attribute.

3.SELECT ASSIGNMENT_NUMBER,EMPLOYEE_NUMBER,PROJECT_NUMBER,ASSIGN_CHARGE,ROUND(ASSIGN_CHG_HOURS *ASSIGN_HOURS,2) ORDER BY ASSIGNMENT_NUMBER DESC;

4.SELECT E.EMPLOYEE_NUMBER,E.EMPLOYEE_LNAME,SUM(ASSIGN_HOURS),SUM(ASSIGN_CHARGE) ORDER BY EMPLOYEE_NUMBER DESC GROUP BY EMPLOYEE_NUMBER;

group by groups the similar type of tuples based on a common attribute and retrieve it as one tuple.similarly sum() is used to calculate the sum of selected values

5.SELECT PROJECT_NUM,SUM(ASSIGN_HOURS),SUM(ASSIGN_CHARGE) FROM ASSIGNMENT GROUP BY PROJECT_NUM;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote