Avatar of Big Monty
Big Monty
Flag for United States of America

asked on 

count number of records for each day

I'm attempting to create a query that'll return to me the number of records for a given date range.
[code]
declare @startDate datetime = '2020-01-01';
declare @endDate datetime = '2020-04-01';

select Date_Added, count( BookingID ) as Total
from bookings
where In_Jail = 1 and Date_Added <= @endDate
group by Date_Added
order by 1 desc;
[/code]

In_Jail tells me if the inmate is still in jail, 1 = true, 0 = false. Right now it's giving me the total number per day, and what I want is to have it tell me the total amount of inmates actively in the jail.

I think I'm pretty close, but am having trouble getting over that last piece, so any help is greatly appreciated!
SQLMicrosoft SQL Server

Avatar of undefined
Last Comment
arnold

8/22/2022 - Mon