Vivek ab Vivek ab - 5 months ago 9
SQL Question

how do i get the sum of hours less than given year and week

I have the following table



how do i get the sum of hours that is less than 2015 week 25

please note it has 2014 values also eg: 2014 week 30

Answer
SELECT sum(hours) WHERE (year = 2015 AND week < 25) OR year < 2015

This will capture anything less than that week. Include all weeks/years prior to 2015.

it has 2014 values also eg: 2014 week 30