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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:47:36+00:00 2026-06-14T23:47:36+00:00

The query below retrieves weather data from a MySql database, and groups this data

  • 0

The query below retrieves weather data from a MySql database, and groups this data in to an hourly format.

select hour(datetime) AS hour
     , avg(Temperature) as AVGT 
from Database.minute
WHERE DATETIME
      BETWEEN (CURDATE() + INTERVAL (SELECT hour(NOW())) hour - INTERVAL 23 hour)
         AND ((CURDATE() + INTERVAL (SELECT hour(NOW())) hour))
group by hour
order by  (CURDATE() + INTERVAL (SELECT hour(NOW())) hour - INTERVAL 23 hour)

Output is as follows:

hour    AVGT
19     11.730
20     11.970
21     11.970
22     11.760
23     11.660
0      11.700
1      11.830
2      12.370
3      12.770
4      12.840
5      12.840
6      12.540
7      12.500
8      12.030
9      12.100
10     12.300
11     12.060
12     11.090
13     10.920
14     10.920
15     10.820
16     10.760
17     10.690
18     10.560

The time is now 18:15. All of the above output is correct apart from the data gathered for hour ’18’. Instead of getting the average value between 18:00 and 18:15, it just outputs the average at time 18:00. ie. ignoring data between 18:01 and 18:14.

How can I modify the above query to include data in the current hour (18:00 to Now)?

Thanks

  • 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-14T23:47:37+00:00Added an answer on June 14, 2026 at 11:47 pm

    Why don’t you simply try

    SELECT Hour(datetime)   AS hour, 
           Avg(temperature) AS AVGT 
    FROM   DATABASE.minute 
    WHERE  datetime BETWEEN ( Curdate() + INTERVAL (SELECT Hour(Now())) hour - 
                              INTERVAL 23 hour ) AND Now() 
    GROUP  BY hour 
    ORDER  BY ( Curdate() + INTERVAL (SELECT Hour(Now())) hour - INTERVAL 23 hour ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On the query below I keep getting this error: Cannot read the next data
the query below is a query that will get data from a column to
Why does the MySQL query below give error 1066 (Not unique table/alias: 'customer') ?
I have a query which retrieves Some data. I want to display that data
I have the following Django Model which retrieves 3 records from a database. The
I have the below query, which basically it retrieves the 5 top most books
I have a query below where a user will type in a term from
I have a database function that retrieves data and then populates a jtable. I
I created a simple wcf service that retrieves data from crm 4.0 using the
I would like to execute the below query by passing some values from applet

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.