65.1k views
5 votes
Division (DID, dname, managerID)

Employee (empID, name, salary, DID)
Project (PID, pname, budget, DID)
Workon (PID, EmpID, hours)
1. List the total number of projects that 'engineering' division employees are working on

1 Answer

2 votes

Answer:

Assuming 'engineering' is the name of the division in the 'dname' field of Division table, the query would look like this:

SELECT COUNT(DISTINCT p.PID)

FROM Project p

JOIN Division d ON p.DID = d.DID

JOIN Workon w ON p.PID = w.PID

JOIN Employee e ON w.EmpID = e.empID

WHERE d.dname = 'engineering';

This query operates by joining the necessary tables together and counting the distinct number of project IDs (PID) associated with the 'engineering' division.

User Zaaath
by
8.1k points