Skip to content
Advertisement

Count all the entity between periods – SQL Server

I want to count all the entities that created between August 1 until May 31 for each year. (academic year)

I am successful counting it monthly, but it’s not good enough:

Can someone help me with this? Thanks.

Advertisement

Answer

you can try this :

Explanation : when the month is small than 6 then it’s part of (year – 1) and year, else it’s part of year and (year + 1)

and to make sure that data of month 6 and 7 is not calculated in case there is wrong data in the database you can add this condition:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement