SELECT and INNER JOIN Question - is it possible??

  • Hi All:

    I have a rather tricky SQL to write. Depending on the value of an INNER JOIN, I need to SUM the data in one value or another one. I tried this to no avail. Thanks for any help or suggestions.

    Bill

    SELECT A.Incident_Id AS Incident#,

    CAST(SUM(B.Billing_Time) AS decimal(8,2)) AS Incident_Bill,

    CAST(SUM(B.Absorbed_Time) AS decimal(8,2)) AS Incident_Abs,

    CAST(SUM(B.Actual_Time) AS decimal(8,2)) AS Incident_Actual,

    CAST(SUM(E.Billing_time) AS decimal(8,2)) AS Solmon_Bill,

    CAST(SUM(D.Billing_Time) AS decimal(8,2)) As Task_Bill,

    CAST(SUM(D.Absorbed_Time) AS decimal(8,2)) As Task_Abs

    FROM Incident as A

    INNER JOIN Inc_HistoryB ON A.Incident_Id = B.Incident_Id WHERE B.Event_Type_ID <> 1810

    INNER JOIN Task C ON A.Incident_Id = C.Entity_ID

    INNER JOIN Task_History D ON C.Task_ID = D.Task_ID

    INNER JOIN Inc_HistoryE ON A.Incident_Id = E.Incident_Id WHERE E.Event_Type_ID = 1810

    GROUP BY A.Incident_Id

    ORDER by A.Incident_Id

  • Please don't cross post.

    Answered here: http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=299392

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply