Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   MySQL (https://www.askmehelpdesk.com/forumdisplay.php?f=442)
-   -   SQL - join (https://www.askmehelpdesk.com/showthread.php?t=447123)

  • Feb 14, 2010, 07:38 PM
    Kygall
    SQL - join
    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!
  • Feb 14, 2010, 07:47 PM
    ScottGem

    First we would need to know the table structures. But your WHERE clause makes no sense. You are comparing apples and oranges.
  • Feb 17, 2010, 05:33 AM
    _Rab_

    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'

  • All times are GMT -7. The time now is 11:53 PM.