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!
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.