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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:21:36+00:00 2026-06-01T00:21:36+00:00

Consider the following messages table: _date message ————————- 2012-02-22 hello 2012-02-22 another msg! 2012-03-05

  • 0

Consider the following “messages” table:

_date        message
-------------------------
2012-02-22   hello
2012-02-22   another msg!
2012-03-05   foobar
2012-03-22   testing
2012-03-22   goodbye
2012-03-22   test test

I want to count the number of messages per day, but also want to include all the days on which there are no messages. Say I want to count all messages between 2012-02-01 and 2012-03-29, then the query result should be:

_date        messsages
----------------------
2012-02-01   0
2012-02-02   0
...
2012-02-22   2
2012-02-23   0
...
2012-03-01   0
2012-03-02   0
2012-03-03   0
2012-03-04   0
2012-03-05   1
...
2012-03-22   3
...
2012-03-29   0

Is this possible within MySQL?

  • 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-01T00:21:37+00:00Added an answer on June 1, 2026 at 12:21 am

    Something like this should do it –

    SELECT date_range.`date`, COUNT(messages._date)
    FROM (
        SELECT '2012-02-01' + INTERVAL (id - 1) DAY AS `date`
        FROM dummy
        WHERE id BETWEEN 1 AND 58
        ORDER BY id ASC
    ) AS date_range
    LEFT JOIN messages
        ON date_range.`date` = messages._date
    GROUP BY date_range.`date` ASC
    

    For this example dummy is any table with an integer based id field with a contiguous set covering the required date range. In this case you would need ids from 1 to 58.

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

Sidebar

Related Questions

Consider the following database tables: Table messages with 13,000,000 rows (one row per message).
Consider the following code: public ObservableCollection<Message> Messages { get { return new ObservableCollection<Message>(); }
Consider the following code: std::string my_error_string = Some error message; // ... throw std::runtime_error(std::string(Error:
Consider the following code: [Test] public void WidgetTest() { foreach (Widget widget in widgets)
Consider the following method: /** * Set whether messages are printed to System.out. *
I'm stuck on a SQL query. Consider the following table: Table DG_GAME_ROUNDS RoundId int
Please consider the following scenario in BizTalk 2006: Received message should be routed to
Consider the following test 1 code struct A { private: class face; friend class
Consider the following jsf page: <h:body> <h:form id=SessionStartDialog> <table> <tr> <td class=label> <h:outputLabel value=Enter
The Requirements I have a following table (pseudo DDL): CREATE TABLE MESSAGE ( MESSAGE_GUID

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.