Я, вероятно, разрываюсь на части, спрашивая, но почему они дают разные результаты при сравнении Claims_Completed в 2 разных сценариях?Значения Claims_Completed совпадают со значениями Claims_Received в обоих сценариях.
SELECT
DischargeType
,COUNT(CASE WHEN (DateReceived > '2/1/2015' AND DateReceived < DATEADD(dd, 1, '2/28/2015')) THEN 1 ELSE 0 END) AS Claims_Received
,COUNT(CASE WHEN (DateCompleted > '2/1/2015' AND DateCompleted < DATEADD(dd, 1, '2/28/2015')) THEN 1 ELSE 0 END) AS Claims_Completed
FROM Claims GROUP BY DischargeType
Сценарий 2:
SELECT COUNT(*) AS Claims_Received
FROM Claims
WHERE DateReceived > '2/1/2015' AND DateReceived < DATEADD(dd, 1, '2/28/2015')
GROUP BY DischargeType
SELECT COUNT(*) AS Claims_Completed
FROM Claims
WHERE DateCompleted > '2/1/2015' AND DateCompleted < DATEADD(dd, 1, '2/28/2015')
GROUP BY DischargeType