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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:08:20+00:00 2026-06-18T04:08:20+00:00

I apologize if this has been asked before.. I’m very new to developing and

  • 0

I apologize if this has been asked before.. I’m very new to developing and although I’ve tried searching a lot, I’m not really sure what to look for.

Anyway so I have a table which counts records being entered per day. It looks something like this (each record is represented by a letter) (assume today’s date is 27/01/2013):

RECORD | COUNT | DATE 
------A-----|-----4-----|27/01/2013  
------B-----|-----7-----|27/01/2013
------B-----|-----3-----|24/01/2013
------C-----|-----8-----|22/01/2013 
------A-----|-----2-----|19/01/2013   

Each new post is checked in the table and it updates the count if the record already exists on the current day, otherwise a new record is created.

For the page which prints the records which have been added ‘TODAY’, I have the MySQL query

SELECT * FROM `table` ORDER BY `date` DESC, `count` DESC LIMIT 1000

and use a php ‘if’ statement to only print the records where the date(‘Y-m-d’) = date in the table. So only the records and the corresponding count which has been entered that day are printed.
– the table above would produce the result:

1. B 7 
2. A 4

What I would like is a page which prints the records which have been entered in the last week. I know I can use DATE_SUB(now(),INTERVAL 1 WEEK) AND NOW(), to print the records from last week but I need to duplicate records to be combined and the counts added together.. so the result for this table would look like this:

1. B 10
2. C 8 
3. A 4

How would I go about combining those duplicate records and have a list of records ordered by count? Is this the best method to get a ‘last week’ record count, or is there another table structure which would be better?

Again I’m sorry if this a silly question or if my explanation was long-winded, but just some simple pointers will be really appreciated.

  • 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-18T04:08:21+00:00Added an answer on June 18, 2026 at 4:08 am

    Try this

    SELECT `record`, SUM(`count`) AS `count` 
      FROM `table` 
     WHERE `date` > DATE_SUB(CURDATE(),INTERVAL 1 WEEK)
     GROUP BY `record`
     ORDER BY `count` DESC 
    

    And you can LIMIT 1000 grouped resultset if you need to

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

Sidebar

Related Questions

I apologize if this has been asked before, I tried searching for it and
I apologize if this question has been asked before. I am relatively new to
I apologize if this has been asked before. I searched but did not find
I apologize if this has been asked and answered before but I was not
First off, I apologize if this has been asked before. I can't seem to
I apologize if this has already been asked - I'm not certain of the
I apologize if this has been asked before, but I haven't quite found the
First, I apologize if this has been asked before - indeed I'm sure it
I'm sorry if this question has been asked before, I've tried googling/looking on here/browsing
I apologize if this question has been asked before, but my case is a

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.