我試圖找出如何在這種情況下使用MAX()。 在此查詢的結果中,我有重複項,我只想找到一個最新記錄(這裏是日期:CL.CL_DATE_FROM),並通過db1.IDF和O.IDp對其進行重複數據刪除。SQL查詢 - 最大和重複
SELECT
db1.IDF as IDF,
O.IDp as IDP,
O.Action as Action,
U.USR_IDENT as Operator,
O.ID_T as ID_T,
OC.OC_MEMO as MEMO,
CONVERT(VARCHAR(10),CL.CL_DATE_FROM,120) as date,
CONVERT(VARCHAR(8),CL.CL_DATE_FROM,108) as time
from OUTBOUND OC
join CALL CL on CL.CL_ID= OC.OC_CL_ID
join CAMPAIGN CA on CA.CA_ID = OC.OC_CA_ID
join STATUSES ATT on ATT.AS_ID = OC.OC_AS_ID
join USERS U on U.USR_ID = OC.OC_USR_ID
join Outbound_Z O on O.ID = OC.OC_CUS_ID
join db1.dbo.Clients db1 on db1.ID_T = O.ID_T
where CL.CL_DATE_FROM BETWEEN '2013-03-05 00:00:00.000' AND '2013-03-05 23:59:59.000'