为什么“子查询返回了多个值”?

时间:2019-06-28 04:25:44

标签: sql-server

我运行以下查询,但得到了:

  

子查询返回了多个值。当子查询遵循=,!=,<,<=,>,> =或将子查询用作表达式时,不允许这样做。

UPDATE Maid 
SET Maid_Hours = (SELECT SUM(c.Duration_Hours) 
                  FROM Appointments
                  LEFT JOIN Duration c ON Duration_ID = Appointment_Duration 
                  WHERE WO_MaidName = 4
                    AND (IsDelete = 0 OR IsDelete = NULL)
                    AND DATEPART(m, Appointment_DateTime) = DATEPART(m, DATEADD(m, -1, getdate()))
                    AND DATEPART(yyyy, Appointment_DateTime) = DATEPART(yyyy, DATEADD(m, -1, getdate()))
                  GROUP BY Appointment_Duration)
WHERE Maid_ID = 4

0 个答案:

没有答案