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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:37:28+00:00 2026-06-02T03:37:28+00:00

I have a MySQL Database That Looks like This: Name: Joe Items: 25 CreationDate:

  • 0

I have a MySQL Database That Looks like This:

Name: Joe
Items: 25
CreationDate: 2012-04-14 18:49:50

Name: John
Items: 89
CreationDate: 2012-04-14 18:47:17

Name: Bill
Items: 95
CreationDate: 2012-04-09 12:34:08

Name: Bob
Items: 35
CreationDate: 2012-04-09 12:18:23

What I want to do is group the rows by CreationDate (Based on only the day, the time at the end should not be a factor). And Then Add the Items Together to come up with an Items / Day.

So I want the output to be something like this:

2012-04-09 - 130 items
2012-04-14 - 114 items

I’ve tried the Group By in MySQL but I’m not sure if i’m using it right:

$sql = mysql_query("SELECT SUM(Items), CreationDate FROM People GROUP BY CreationDate ORDER BY CreationDate DESC") or die(mysql_error());
while($row = mysql_fetch_array($sql) ) {
    echo '<p>' . $row['CreationDate'] . ' - ' . $row['SUM(Items)'] . '</p>';
}

That kind of works except it Groups them only on exact match Creation Date (Down to the second) and i’m not sure how to fix for that.

  • 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-02T03:37:30+00:00Added an answer on June 2, 2026 at 3:37 am

    You need to use the date-function for the CreationDate field, such as:

    SELECT SUM(Items), DATE(CreationDate) FROM People GROUP BY DATE(CreationDate) ORDER BY CreationDate DESC
    

    A warning though: Using the DATE-function will ignore any index on the CreationDate. If the CreationDate-field is indexed, using the DATE-function and grouping on it will take much longer time.

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

Sidebar

Related Questions

I have a MySQL database that looks like this: users ( id , name
I have a mysql database that looks like this: |id | city | created
OK I have a mySQL Database that looks something like this ID - an
I have a MySQL database that looks similar to this: ID Group Name 1
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
I have an application config file that looks something like this: database: type: [db-type]
I have two tables in a database that looks like this members table1 id
I have a mysql database that is tracking hockey stats. What I'd like to
I have a MySQL user added to a database that I would like to
I have to look into solutions for providing a MySQL database that can handle

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.