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 7583459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:40:56+00:00 2026-05-30T18:40:56+00:00

I trying to get the Grape count from dates March 1 – 3. You

  • 0

I trying to get the Grape count from dates March 1 – 3.

enter image description here

You will notice that on March 2 – there are no grapes inserted..

I’st possible to show a query from dates March 1, 2 and 3 but showing 0 count for March 2
enter image description here

In this image above only shows dates where there are grapes..

Here is mySQL query

SELECT  `fruitDate` ,  `fruitName` , COUNT( * ) 
FROM  `tbl_fruits` 
WHERE  `fruitName` =  "Grapes"
GROUP BY  `fruitDate

UPDATE 2:

Using this query:

SELECT f.fruitDate, f.fruitName, f1.count FROM tbl_fruits f
    LEFT JOIN (SELECT fruitDate, COUNT(*) as count from tbl_fruits d WHERE d.fruitName='Grapes' GROUP BY d.fruitDate) as f1 ON (f.fruitDate = f1.fruitDate) 
    GROUP BY f.fruitDate

I got this result..but its dsplaying diffrent fruit..something wrong with my query?

enter image description here

  • 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-05-30T18:40:58+00:00Added an answer on May 30, 2026 at 6:40 pm

    Remember there is a dynamically (and a bit ugly) solution to creating a date range that does not require creating a table:

    select aDate from (
      select @maxDate - interval (a.a+(10*b.a)+(100*c.a)+(1000*d.a)) day aDate from
      (select 0 as a union all select 1 union all select 2 union all select 3
       union all select 4 union all select 5 union all select 6 union all
       select 7 union all select 8 union all select 9) a, /*10 day range*/
      (select 0 as a union all select 1 union all select 2 union all select 3
       union all select 4 union all select 5 union all select 6 union all
       select 7 union all select 8 union all select 9) b, /*100 day range*/
      (select 0 as a union all select 1 union all select 2 union all select 3
       union all select 4 union all select 5 union all select 6 union all
       select 7 union all select 8 union all select 9) c, /*1000 day range*/
      (select 0 as a union all select 1 union all select 2 union all select 3
       union all select 4 union all select 5 union all select 6 union all
       select 7 union all select 8 union all select 9) d, /*10000 day range*/
      (select @minDate := '2001-01-01', @maxDate := '2002-02-02') e
    ) f
    where aDate between @minDate and @maxDate
    

    Depending on the length of the date range you can reduce the amount of dynamically generated results (10000 days means over 27 years of records each representing one day) by removing tables (d, c, b and a) and removing them from the upper formula. Setting the @minDate and @maxDate variables will allow you to specify the dates between you want to filter the results.

    Edit:

    I see you’re still looking for a solution. Try this:

    select c.date, f.fruitName, count(f.fruitName = 'Grapes')
    from tbl_calendar c
    left join tbl_fruits f
    on c.date = f.fruitDate and f.fruitName = 'Grapes'
    group by c.date, f.fruitName
    

    If you also want to filter the extra dates from the created table, use this query:

    select c.date, f.fruitName, count(f.fruitName = 'Grapes')
    from tbl_calendar c
    left join tbl_fruits f
    on c.date = f.fruitDate and f.fruitName = 'Grapes'
    group by c.date, f.fruitName
    having c.date between
      (select min(fruitDate) from tbl_fruits) and
      (select max(fruitDate) from tbl_fruits)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to get comfortable with jQuery and I have encountered some sample code that
I am trying to get updates when the like count of a page my
I am using cakephp. I am trying get data from facebook using file_get_contents. I
I am trying to get my graph to display dates on the x axis
Here is my code: I am trying to get the CSV files from a
I'm trying to count the amount of A 's there are in a school
I am trying to get the count of tagged photos for a user. When

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.