MySQL Forums
Forum List  »  Newbie

Re: Finding min é max values for each day
Posted by: Peter Brawley
Date: November 28, 2017 02:12PM

Not a Show Create Table result.

There's a typo in the query, reversing maxs & mins, should be ...

select mm.d, mm.mintemp, time( as mintime, mm.maxtemp, time( as maxtime 
from ( 
  select date(date) as d, min(temp_ext) as mintemp, max(temp_ext) as maxtemp 
  from releves 
  group by d 
) mm 
join releves as mins on mm.d=date( and mm.mintemp=mins.temp 
join releves as maxs on mm.d=date( and mm.maxtemp=maxs.temp

BTW column names should as far as possible be self-documenting; `date` misleadingly suggests it's type date, but it's type datetime, needs a name indicating that.

Options: ReplyQuote

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.