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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:16:49+00:00 2026-05-27T05:16:49+00:00

I am trying to make a query to get data from a database, but

  • 0

I am trying to make a query to get data from a database, but I can’t get it done.

I have the following table with dummy data:

id | date  

0  | 2011-11-25 20:12:32
1  | 2011-11-15 20:12:32
2  | 2011-11-05 20:12:32
3  | 2011-10-25 20:12:32
4  | 2011-10-15 20:12:32
5  | 2011-10-05 20:12:32
6  | 2010-10-25 20:12:32
7  | 2010-04-25 20:12:32
8  | 2009-07-25 20:12:32

I want to make a query that:

  • Sorts the date by Year, then Month and then the Day
  • Then it should count how many time of every month in these years there are.

If you don’t get what I mean:
It should give a result something like this (using the dummy data from the table):


Year | Month | amount (of rows with that month in that year)

2011 | 11    | 3
2011 | 10    | 3
2010 | 4     | 2
2009 | 7     | 1

I have some knowledge of mySQL, but this is to much for me. 🙂

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-05-27T05:16:50+00:00Added an answer on May 27, 2026 at 5:16 am
    SELECT YEAR(`date`)  AS `year`, 
           MONTH(`date`) AS `month`, 
           COUNT(*)      AS amount 
    FROM   `table` 
    GROUP  BY YEAR(`date`), 
              MONTH(`date`) 
    ORDER  BY `date` DESC 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make one query, to get some statistic data from database.
I'm trying to make a class that takes some unspecified data from a database
I'm trying to get data from database, and echo them on the page using
I'm trying to make a website which gets some data from database and generate
I've been trying to figure out how I can make a query with MySQL
I have this situation where I need to get some data from a webpage
I am trying to create an SSIS package that queries data from a table,
I have been trying to make OOP PHP5 code. But I think my attempts
I am trying to insert data in table in mysql database through php code
Trying to make a make generic select control that I can dynamically add elements

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.