In SQL , How to get min / max date in the count , group by query?
Query :
-- This doesn't give Min and Max date received for the file
;with cte as
(
select SourceId,Count(FileName) as TotalFileCount
from mytable
group by SourceId
)
select * from cte
order by TotalFileCount desc
Expected output .. is along with the SourceId, Count, StartDate(Minimum), EndDate(Maximum)