MySQL Forums
Forum List  »  Newbie

Query to return date and time of event
Posted by: Patrick Simonds
Date: December 11, 2014 04:28PM

I have a table that stores years of weather data. There is 1 line of data for each minute in a day (1440 lines per day). What I want is to get the max temperature for each day and at what time it happened.

I can get the the max temp for each day but am unable to get the time it occurred. Since there is a line for each minute in the day the max temp will normally happen on more than 1 line. I just need to know the first time it happened each day.

Any thoughts out there as to how to get this to work?


CREATE 
    ALGORITHM = UNDEFINED 
    DEFINER = `root`@`localhost` 
    SQL SECURITY DEFINER
VIEW `view_maxtemp_record` AS
    SELECT 
        `weatherhistorical`.`EventDate` AS `Date`,
        `weatherhistorical`.`EventTime` AS `Time`,
        MAX(`weatherhistorical`.`TempOut`) AS `TempOut`
    FROM
        `weatherhistorical`
    GROUP BY `weatherhistorical`.`EventDate`

Options: ReplyQuote


Subject
Written By
Posted
Query to return date and time of event
December 11, 2014 04:28PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.