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

  • Home
  • SEARCH
  • 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 9124123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:30:09+00:00 2026-06-17T06:30:09+00:00

I have the following query which gets year,Sum data between from and to date.

  • 0

I have the following query which gets year,Sum data between from and to date.
It works perfectly.

SELECT strftime('%Y',Date), SUM(Amount) 
from table where  (Date between '2008-08-01' and '2012-07-31') 
GROUP BY strftime('%Y',Date)

I am displaying the sum on a bar chart.
Now If I click on the respective year it should show all the transactions till the “To Date” for that year or if the value is smaller than “To date” then the entire year’s transaction.

For Eg: In the example above it displays Sum From Date : 2008-08-01 and To Date: 2012-07-31 .

If the user taps on the year 2012 bar column it should show transactions till the date 2012-07-31 and not for the entire year but if the user taps on 2011 it should transaction for the entire year as the TO Date is greater than 2011 year.

Same for the year 2008, it should display data from “2008-08-01” not the entire year and if I tap the bar column of that year it should show the transactions from that particular date till the end of the year and not for the entire year.

I have the query below which returns wrong value .

SELECT strftime('%Y',Date) ,* 
from table where (Date between '2011-08-01' and '2012-07-31') 
                 and strftime('%Y',Date)='2012' 
GROUP BY strftime('%Y',Date)

This returns only one row for the date 2012-01-01 not all the values for the year 2012 till 2012-07-31.

Basically I would like to change only year in the following query and rest should be same. strftime(‘%Y’,Date)=’2012′

I don’t know how to fix it or How to go about it w.r.t the above requirement.
Please help me fix it or Any Alternative. Thanks in Advance.

  • 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-17T06:30:10+00:00Added an answer on June 17, 2026 at 6:30 am

    You don’t need GROUP BY

    SELECT strftime('%Y',Date) ,* 
    from table where (Date between '2011-08-01' and '2012-07-31') 
                     and strftime('%Y',Date)='2012' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query which have 1000 rows select staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate), EmployeeID from tblEmployees
I have the following query which works: SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(42.883, -72.8981)))
I have the following code which gets a users data from a table based
I have an application which gets some data from a remote database. I use
I have the following query: SELECT AVG(time) FROM (SELECT UNIX_TIMESTAMP(max(datelast)) - UNIX_TIMESTAMP(min(datestart)) AS time
I have the following code which creates an array. $qry=SELECT foo_id, foo1, foo2 FROM
I have the following MySQL query which gets all the bookings for an agent,
I have a method which gets the whole data from a View inside my
I have the following PHP which basically gets the result of a MySQL query:
So I have the following query which gets a Duplicate PK error what am

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.