sql server - SQL Count sickness days -


i have sql server table contains list of staff , sickness.

i need able calculate how many days have had sick in current quarter

the issue is, people may have been sick year so, e.g fromdate 2013-12-31 , untildate 2014-12-31 (1 year sickness leave). should count days sickness occur in current quarter. should around 90 days of sickness rather count entire year.

current sql

select sum(a.workdays) total absence a.fromdate < getdate() ,   a.untildate > dateadd(month, -3, getdate()) , a.abs_reason='sick' 

so @ moment, takes fromdate correct need account people sick before quarter started still sick going current quarter should count number of days when quarter started until end of quarter.

any appreciated.

with table of dates, find count of dates date between 2 dates of interest, , there exists leave period surrounds it. filter dates exclude non-business days , public holidays.

there lots of ways generate such table of dates, , plenty described both on stackoverflow , dba.stackexchange.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -