mysql - Select highest range of data -


my table consists of temperatures column filled db every 10min, , find out when , maximum daily range temperatures current month

this select max daily temp

select logdatetime, max(temp) sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) 

and min daily temp

select logdatetime, min(temp) sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) 

and need tie them together.. max value - min value

you can

select logdatetime, max(temp) `max`, min(temp) `min` , max(temp) - min(temp) `diff` sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) 

i above query calculation min max twice reduce 1 subselect

select t.* ,t.`max` - t.`min` `diff`  from(     select logdatetime, max(temp) `max`,     min(temp) `min`      sibeniku_monthly     date_format(logdatetime, "%m.") = 04     group day(logdatetime) ) t 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -