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

For these exercises, we use the Employees Database presented at the end of Chapt

ID: 3702532 • Letter: F

Question

For these exercises, we use the Employees Database presented at the end of Chapter 1. Answer each question with a single SQL statement. Your query must work for any set of data in the Employees Database, not just the set of data we provide.

7. For each project, find the greatest percentage of time assigned to one employee. Solve it two ways: 1) using only WHERE-based join (i.e., no INNER/OUTER/CROSS JOIN) and 2) using some form of JOIN.

24 Chapter I:Databasks projects projectd deparmenls code managerid subdeplof description startdate encdate revenue workson empore edi assignedime employeeld firstname lastname deplcode salary Figure 1.5: Schema for the Imployees Database

Explanation / Answer

If you have any doubts, plese give me comment...

SELECT projectid, MAX(TotalTime) AS AS greatest
FROM (SELECT employeeid, projectid, SUM(assignedtime) AS TotalTime
    FROM workson w, employees e
    GROUP BY projectid, employeeid) AS Temp
GROUP BY projectid;


SELECT projectid, MAX(TotalTime) AS AS greatest
FROM (SELECT employeeid, projectid, SUM(assignedtime) AS TotalTime
    FROM workson INNER JOIN employees
    WHERE employeeid = employeeid;
    GROUP BY projectid, employeeid) AS Temp
GROUP BY projectid;