mysql - Calculating amout of minutes between 2 times and divide it by amount of records -
how can calculate amount of minutes between 9 , 11 of records togther (colum generated). want know how can devide output of amount of records there are.
select address, min(from_unixtime(time)) "aankomsttijd", max(from_unixtime(time)) "eindtijd", timestampdiff(minute, min(from_unixtime(time)), max(from_unixtime(time))) "minuten" sensordata1 from_unixtime(sensordata1.time) between '2017/04/04' , '2017/04/05' , from_unixtime(sensordata1.time, '%h') between 9 , 11 group address having minuten > 2 , minuten < 1400
normal database can see "minuten not real column"
what want minutes 1 amount , want devide amount of records calculated minutes together.
you can use query wrote source calculation want, like
select sum(minuten) total_minuten, count(*) records, sum(minuten) / count(*) average_minuten ( select address, min(from_unixtime(time)) "aankomsttijd", max(from_unixtime(time)) "eindtijd", timestampdiff( minute, min(from_unixtime(time)), max(from_unixtime(time)) ) "minuten" sensordata1 from_unixtime(sensordata1.time) between '2017/04/04' , '2017/04/05' , from_unixtime(sensordata1.time, '%h') between 9 , 11 group address having minuten > 2 , minuten < 1400 ) t1
Comments
Post a Comment