SQL Loop Count of people in program during specified duration

Multi tool use
Multi tool use


I'm not sure if there should be a loop for this or what the easiest approach would be.



My data consists of a list of people participating in our program. They have various start and end dates, but the following equation is able to capture the number of people who participated on a specific date:



Is there a way I can loop in different date values to get the number of program participants each day for an entire year?
Multiple years?



One simple way is to use a CTE to generate the dates and then a left join to bring in the data. For instance, the following gets the counts as of the first of the month for this year:



Note that this will work best for a handful of dates. If you want more than 100, you need to add option (maxrecursion 0) to the end of the query.



Also, count(people) is highly suspicious. Perhaps you mean sum(people) or something similar.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

i5,a6KhKub,Pp887Y5I,eScGNgZF qTKDKSuRBrRnm,PY60fBle
GBfDVRZke7ScLFGq,Z 5IF,qNxcJk9jzIL9dpzFZAzz3m VXkj3G,u tFGe9 v wGjhxrLSRqtmK jQL,t7Xlsy,dd,WRVARO

Popular posts from this blog

The Dalles, Oregon

영화 미래의 미라이 다시보기 (2018) 다운로드 링크 무료보기

Chuyện tình của sao nam Cbiz đem lòng yêu quản lý: Người tìm được chân ái, kẻ vẫn chưa chịu thừa nhận