我正在使用sql server。我需要有关计数查询的帮助,该查询将为我提供当前日期,而无需手动更改日期?为什么我得到重复的行。我的总数超过了43,000行,而不是我真正拥有的300行。这是我的查询。
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()),
0),CatID,status,IncomingSubject,count(CatID)
FROM CCMDB.dbo.InboundCorrespondenceDetails
WHERE CatID in('cat0014')
AND IncomingType = 'RITS'
AND status = 'Completed'
GROUP BY CatID,IncomingSubject,status
ORDER BY MAX(ReceivedDate) ASC