Hello I am trying to write a case statement that has a 1 year interval in this case the year starts at April and ends march of the following year, however If for example march of this year is entered then it would be the end of last year due to the fact that, the year would have started from last year April
Have a look at the sqlfiddle here
and this is the code that I have so far, note the
sum(case
when Month(py.pay_date) = 4 interval())1 year
then amount end) yearly_amount
This is where I am having the major problem
You can use this for your
yearly_amountcalculation for the current year (starting in april and ending at the end of march in the next year):SQLFiddle Demo