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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:11:01+00:00 2026-05-28T08:11:01+00:00

So I’ve got a MySQL database that counts the number of servers with given

  • 0

So I’ve got a MySQL database that counts the number of servers with given usage levels on an hourly basis, as such:

Date                Status  Population
2012-01-13 15:33:40 UP      Standard
2012-01-13 15:33:40 UP      Light
2012-01-13 15:33:40 UP      Heavy
2012-01-13 15:33:40 UP      Light

2012-01-13 16:33:40 UP      Light
2012-01-13 16:33:40 UP      Very Heavy
2012-01-13 16:33:40 UP      Light

etc.

and a query that counts the number of servers with given usage levels grouped by minute, thusly

SELECT DATE, ROUND( UNIX_TIMESTAMP( DATE ) / ( 1*60 ) ) AS TIME, COUNT( IF( POPULATION =  "Light", 1, NULL ) ) AS LightCount, COUNT( IF( POPULATION =  "Standard", 1, NULL ) ) AS StandardCount, COUNT( IF( POPULATION =  "Heavy", 1, NULL ) ) AS HeavyCount, COUNT( IF( POPULATION =  "Very Heavy", 1, NULL ) ) AS VeryHeavyCount, COUNT( IF( POPULATION =  "Full", 1, NULL ) ) AS FullCount, COUNT( IF( POPULATION =  "Offline", 1, NULL ) ) AS OfflineCount
FROM  `Servers` 
GROUP BY TIME
ORDER BY DATE ASC

The output looks like:

DATE            TIME            LightCount  StandardCount   
2012-01-13 15:33:40 22108174    16          146     
2012-01-13 16:33:35 22108180    16          147 

and so on, with running counts for every hour.

I’m trying to find a way to determine the highest number of “LightCount” or “StandardCount” etc. within each 24 hour period. In other words, what was the highest hourly LightCount for any given day?

Is this at all possible? Would it require a nested query of some sort?

Thanks much for any help.

  • 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-28T08:11:01+00:00Added an answer on May 28, 2026 at 8:11 am

    First, you can use GROUP BY DATE(DATE),HOUR(DATE) for hourly sums:

    SELECT `DATE`, COUNT(...), ... -- HOUR(`DATE`) if you wanted to see it
    FROM `Servers`
    GROUP BY DATE(`DATE`),HOUR(`DATE`)
    ORDER BY `DATE` ASC
    

    Then to do maximum hourly counts per day you’d do

    SELECT DATE(`DATE`) as Day, MAX(LightCount) as MaxHourlyLightCount, ...
    FROM (
        SELECT `DATE`, ....
        FROM `Servers`
        GROUP BY DATE(`DATE`),HOUR(`DATE`)
        ORDER BY `DATE` ASC
         ) HourlyCounts
    GROUP BY Day
    

    Here’s a link to the MySQL Date/Time functions — you can do monthly stats with GROUP BY MONTH(``Date``), YEAR(``Date``), yearly stats with GROUP BY YEAR(``Date``), etc – very handy.

    (Note: replace those double-backticks above with single-backticks — I don’t know how to escape them properly in stackoverflow).

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT
I have a reasonable size flat file database of text documents mostly saved in

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.