I am using sql server 2008 R2. I am having a table in database that contains data regarding patients that are of different status like Active, Completed, Inactive etc. I am asked to get the patients with "Active" status group by date.
I have created following query :
SELECT COUNT(*) AS TotalActivePatients, CONVERT(VARCHAR(10), CreatedDtUTC,111) AS CreatedDtUTC
FROM TablePatient
WHERE MonitoringStatus LIKE 'Active'
AND IsDeleted=0
GROUP BY CONVERT(VARCHAR(10), CreatedDtUTC,111)
and that gives me the result like below :
TotalActivePatients CreatedDtUTC
1 2013/02/24
2 2013/02/25
4 2013/02/28
4 2013/03/01
1 2013/03/06
1 2013/03/10
3 2013/03/11
2 2013/03/14
3 2013/03/15
2 2013/03/16
But, It is giving me the number of active patients on specific date. I want the sum of total active patients upto that specific date.
Any solution?
Thanks