SELECT COUNT(DIFF) MaxDate, MinDate, DATEDIFF(D, MinDate, MaxDate)/30 AS DIFF FROM ( SELECT MAX(TDate) AS MaxDate, MIN(TDate) AS MinDate FROM EDATA GROUP BY TCard )a
DIFF 10 5 10 10 5 7
Count 3 2 1
SELECT --COUNT(DIFF) Count(DATEDIFF(D, MinDate, MaxDate)/30) AS DIFF FROM ( SELECT MAX(TDate) AS MaxDate, MIN(TDate) AS MinDate FROM EDATA GROUP BY TCard )a Group by DATEDIFF(D, MinDate, MaxDate)/30
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)