Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:41:06+00:00 2026-06-10T08:41:06+00:00

Hello I am trying to write a case statement that has a 1 year

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:41:08+00:00Added an answer on June 10, 2026 at 8:41 am

    You can use this for your yearly_amount calculation for the current year (starting in april and ending at the end of march in the next year):

    sum(case 
            when py.pay_date >= STR_TO_DATE(CONCAT(YEAR(NOW()), '-04-01'), '%Y-%m-%d') and
                 py.pay_date <  STR_TO_DATE(CONCAT(YEAR(NOW()), '-04-01'), '%Y-%m-%d') + interval 1 year
                 then amount
            end) yearly_amount
    

    SQLFiddle Demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i am trying to write the following function to display 7 days of
Hello I am trying to write a program in python that asks the user
Hello i'm trying to write a program that takes 3 user inputs: file path,
Hello everyone I am trying to write a string on image during runtime and
Hello I was trying to remove objects from object array that I have and
Hello I am trying to write these python lines in a single line but
Hello there i'm trying to write a layout similar to the timepicker widget layout.
I am trying to write a hello world type program for using virtual channels
I'm trying to write a Sinatra app that will run on a shared Passenger
I am trying to write a class that will calculate checksums using multiple processes,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.