0

I have this query and the top inner join works fine but when i add the second join i receive incorrect syntax near 'INNER' anyone any idea why?

SELECT  Time_ID,
    Site_Type_ID,
    SUM (staging.dbo.incoming_measure.ring_time) AS Ring_Time,
    SUM (staging.dbo.incoming_measure.hold_time) As Hold_Time,
    SUM (staging.dbo.incoming_measure.talk_time) AS Talk_Time,
    SUM (staging.dbo.incoming_measure.acw_time) AS ACW_Time
FROM staging.dbo.incoming_measure
      INNER JOIN
   (SELECT Time_ID FROM datamartend.dbo.Time_Dim ) TimeID
      ON TimeID.Time_ID = incoming_measure.StartTime

      INNER JOIN 
   (SELECT Site_Type_ID, Site_Type_Code FROM datamartend.dbo.Site_Type_dim) SiteID
      ON SiteID.Site_Type_ID = incoming_measure.DBID

WHERE StartTimeDate BETWEEN StartTimeDate AND EndTimeDate  
   AND
WHERE SiteId.Site_type_code = incoming_measure.DBID

GROUP BY time_id, site_type_id
4

1 に答える 1

4

WHERE下に移動する必要がありますGROUP BY:

WHERE StartTimeDate BETWEEN StartTimeDate AND EndTimeDate
AND SiteId.Site_type_code = incoming_measure.DBID

Group by time_id, site_type_id
于 2013-03-28T14:47:17.217 に答える