Log in

View Full Version : SQL - join


Kygall
Feb 14, 2010, 07:38 PM
I need help with the following problem.

Calculate the TOTAL actual cost for all over-budget projects managed by the manager named Graves.

I think I'm missing something from my answer, but I'm not sure how to get it.
I've written;
SELECT SUM (ACTUAL_COST)
FROM PROJECT, MANAGER
WHERE PROJECT.ACTUAL_COST = MANAGER.MG_NAME AND MG_NAME = GRAVES

Do I need to calculate the over-budget projects? If so, how do I write that?

Thanks in advance for your help!

ScottGem
Feb 14, 2010, 07:47 PM
First we would need to know the table structures. But your WHERE clause makes no sense. You are comparing apples and oranges.

_Rab_
Feb 17, 2010, 05:33 AM
Like ScottGem says, without your table structure, its difficult to say; however, the following may help you

SELECT SUM(Project.ActualCost)
FROM Project LEFT JOIN Manager ON Project.ManagerID = Manager.ManagerID
GROUP BY Manager.MG_Name
HAVING Manager.MG_Name = 'GRAVES'