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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:56:40+00:00 2026-05-25T16:56:40+00:00

I have the following mysql statement basically doing what I want it to do

  • 0

I have the following mysql statement basically doing what I want it to do except for one thing.

SELECT 
a.tmc, w.date, ROUND(AVG(a.surface_temperature), 0) surface_temperature, ROUND(AVG(a.air_temperature), 0) air_temperature, 
ROUND(AVG(a.material_rate),0) material_rate, 
Time_Format(w.time, '%H:00') as time, 
ROUND(AVG(w.intensity), 0) intensity, 
FROM application a 
LEFT OUTER JOIN weather w ON a.DATE = w.DATE AND a.tmc = w.tmc 
WHERE w.DATE = '" & calendar1.SelectedDate & "' 
AND w.event= '" & weatherType.SelectedItem.Value & "' 
AND w.City = '" & sender.CssClass & "' 
GROUP BY time

This Produces:
enter image description here

This is fine but the problem is there are multiple TMCs per location (Think of TMC’s as fire stations in city. Big Cities have multiple TMCs

What I need it to do is average everything like it does per hour but do it for every tmc, not just the first tmc that comes up based off the time and other filtered criteria.

I attmped both:

GROUP BY TIME AND TMC

and

GROUP BY TMC

but they both provide only 1 time and the 1 location.

How do I need to tweak this statement so it pulls the average of all this criteria per hour per tmc?

I want something with the following output:

Time TMC       Temp
4:00 107+4807   27
4:00 108+3352   32
5:00 107+4807   28
5:00 105+2274   28

I hop this makes sense

  • 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-25T16:56:41+00:00Added an answer on May 25, 2026 at 4:56 pm

    I think you need to comma-separate them:

    GROUP BY time, tmc
    

    It’s perhaps not that clear in the manual page for the SELECT statement:

    [GROUP BY {col_name | expr | position}
          [ASC | DESC], ... [WITH ROLLUP]]
    

    i.e., you can specify multiple columns to form more granular groups.

    When you specify a logical combination like

    GROUP BY TIME AND TMC
    

    things might appear to work, but the groups produced will depend on the ‘logical’ value of time and tmc – you’ll get a group for the rows where both appear ‘true’ and a group for everything else.

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

Sidebar

Related Questions

I have a little problem, have the following statement in mysql: SELECT cmfilm.*, cmgenre.titel
I have written the following SQL statement in MySQL : USE my_database; SELECT *
I have the following MYSQL select statement in a php file that was provided
I currently have the following MySQL statement to replace the HTML entity for a
I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id |
I have an application that executes the following MySQL query: SELECT 402 AS user_id,
I have the following sql create statement mysql> CREATE TABLE IF NOT EXISTS `erp`.`je_menus`
I have the following select statement: $res = mysql_query(select * from Table where Name='{$_REQUEST['name']}');
I have the following SQL statement: mysql_query(SELECT * FROM `friends` WHERE friend1='$username' OR friend2='$username'
After a MySQL select statement, I am left with the following: set([('1@a.com',), ('2@b.net',), ('3@c.com',),

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.