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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:59:41+00:00 2026-06-10T00:59:41+00:00

I am not sure why my numbers are drastically off from each other. A

  • 0

I am not sure why my numbers are drastically off from each other.

A query with no max id:

SELECT id, DATE_FORMAT(t_stamp, '%Y-%m-%d %H:00:00') as date, COUNT(*) as count
FROM test_ips
WHERE id > 0
AND viewip != ""
GROUP BY HOUR(t_stamp)
ORDER BY t_stamp ASC;

I get:

1     2012-07-18 19:00:00     1313
106     2012-07-18 20:00:00     1567
107     2012-07-19 09:00:00     847
225     2012-07-19 10:00:00     5095
421     2012-07-19 11:00:00     205
423     2012-07-19 12:00:00     900
461     2012-07-19 13:00:00     619
490     2012-07-20 15:00:00     729
575     2012-07-20 16:00:00     1682
1060     2012-07-20 17:00:00     2063
2260     2012-07-20 18:00:00     1417
5859     2012-07-20 21:00:00     1303
7060     2012-07-20 22:00:00     1340
8280     2012-07-20 23:00:00     1211
9149     2012-07-21 00:00:00     1675
10418     2012-07-21 01:00:00     721
11127     2012-07-21 02:00:00     825

But if I add a max id:

AND id <= 8279

I get:

1     2012-07-18 19:00:00     1313
106     2012-07-18 20:00:00     1201
107     2012-07-19 09:00:00     118
225     2012-07-19 10:00:00     196
421     2012-07-19 11:00:00     2
423     2012-07-19 12:00:00     38
461     2012-07-19 13:00:00     20
490     2012-07-20 15:00:00     85
575     2012-07-20 16:00:00     483
1060     2012-07-20 17:00:00     1200
2260     2012-07-20 18:00:00     1200
5859     2012-07-20 21:00:00     1201
7060     2012-07-20 22:00:00     1220

The numbers are WAY off from each other. Something is goofy.

EDIT: Here is my table structure:

id  t_stamp             bID      viewip                 unique
1   2012-07-18 19:22:20     5    192.168.1.1        1
2   2012-07-18 19:22:21     1    192.168.1.1        1
3   2012-07-18 19:22:22     5    192.168.1.1        0
4   2012-07-18 19:22:22     3    192.168.1.1        1
  • 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-10T00:59:42+00:00Added an answer on June 10, 2026 at 12:59 am

    Your query is not consistent.

    In your select statement you are displaying the full date.

    But you are grouping your data by the hour. So your count statement is taking the count of all the data for each hour of the day.

    As an example take your first result:

    1 2012-07-18 19:00:00 1313

    The count of 1313 contains the records for all of your dates (7/18, 7/19, 7/20, 7/21, 7/22, etc) that have an hour of 19:00.

    But the way you have your query setup, it looks like it should be the count of all records for 2012-07-18 19:00:00.

    So when you add AND id <= 8279″ The dates of 7/21 and some of 7/20 or no longer being counted so your count values are now lower.

    I’m guessing you are meaning to group by the date and hour and not just the hour.

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

Sidebar

Related Questions

Not sure what I am doing wrong. The results I get from the Accelerate
I am not sure why this works but not when I pass in numbers
I had a look at some other questions but I'm still not sure how
Not sure why i'd be getting such odd numbers when looking at the number
Not sure how far a sql query can go with if/else statements. I have
I'm not sure why this isn't working. I'm trying to display 2 columns from
I am not sure where the distributor/s should run when there is a number
I'm wanting to find the ranking / number of a row. I'm not sure
Not sure whats going on here, or what could be the integer in this
Not sure if im just being stupid or something but here goes i work

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.