2017-04-03 111 views
0

我有一个像mysql的计算总分钟perticular小时

2017-03-22 10:57:01 
    2017-03-22 10:57:09 
    2017-03-22 10:59:35 
    2017-03-22 10:59:55 
    2017-03-22 11:00:01 
    2017-03-22 11:08:16 
    2017-03-22 11:39:07 
    2017-03-22 11:50:37 
    2017-03-22 11:59:57 
    .......... 
ex. 10 AM total minutes worked 45 

    tracking_dtls 

    device_id tracking_dt_time 
     1  2017-03-22 10:57:01 
     1  2017-03-22 10:57:09 
     1  2017-03-22 10:59:35 
     1  2017-03-22 10:59:55 
     1  2017-03-22 11:00:01 
     1  2017-03-22 11:08:16 
     1  2017-03-22 11:39:07 
     1  2017-03-22 11:50:37 
     1  2017-03-22 11:59:57 

From tracking_dtls table calculate total working minutes for a all hours 

数据在这个数据计算工作全部时间分钟,我seprately.how能做到这一点可以请人帮助我。

+0

请添加表结构以及如何让查询结果看起来像。 – suecarmol

+0

如果有人提供这样的数据,你能做些什么吗? – Rams

+0

“时间总计10分钟45”这是什么意思? – Rams

回答

2

您需要聆听并采取时间差最大值减去分钟的组。

select HOUR(tracking_dt_time), 
(TIME_TO_SEC(max(tracking_dt_time))-TIME_TO_SEC(min(tracking_dt_time)))/60 as minutes from tracking_dtls group by HOUR(tracking_dt_time) 
+0

thnks for u r回答 – ganesh

+0

thnks正常工作 – ganesh

+0

欢迎您:) – Rams