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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -