select distinct
assignedTo,
alert_id,
insert_date_time,
alert_status_id,
alert_action_id,
alert_call_reason_id,
target_date
from Case_Management.AlertDetail
工作正常。(看似)簡單查詢的SQL錯誤
select distinct
assignedTo,
alert_id,
max(insert_date_time),
alert_status_id,
alert_action_id,
alert_call_reason_id,
target_date
from Case_Management.AlertDetail
返回,因爲它不是在聚合函數或GROUP BY子句中包含的錯誤列「Case_Management.AlertDetail.assignedTo」在選擇列表中無效。
我很難過。
對於其餘字段,您正在使用不帶「GROUP BY」的聚合函數('MAX')。 – LittleBobbyTables 2013-03-19 19:41:54