0

我有这个查询,顶部的内部连接工作正常,但是当我添加第二个连接时,我在“INNER”附近收到不正确的语法,有人知道为什么吗?

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 回答