I want to access a weather table and sumamrise it in terms of days and months. I want some of the values to be AVG and some to be SUM.
I want to underpin the resulting record with values from the collective data that represent the maximum count but after a few combinations, I have not managed it.
EXAMPLE DATA:
day_date                main_weather     temp
2012-01-01 07:00:00     Cloudy           8.0
2012-01-01 08:00:00     Cloudy           10.0
2012-01-01 09:00:00     Sunny            12.0
2012-01-01 10:00:00     Sunny            16.0
2012-01-01 11:00:00     Sunny            18.0
WANTED RESULT:
DATE(day_date)          MAX(COUNT(main_weather)     AVG(temp)
2012-01-01              Sunny                       12.8
Here's my first SQL to show what I am trying to do:
SELECT 
    DATE(`day_date`), 
    MAX(COUNT(`main_weather`)),    <--- this is the piece I am stuck with the max values.
    AVG(`temp`) 
FROM `sma_weather`
GROUP BY `day_date`;
 
     
     
    