首页 > 解决方案 > 需要计算查询mysql的平均经过时间

问题描述

我需要计算一列数据类型 time(1) 的平均时间。但是,当我运行以下查询时,平均值不正确。考虑到它使用的值,它有点低。任何人都可以帮忙吗?

    $statement2 = $dbhandle->prepare(
"SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(`actualsplit`))) as average 
FROM workoutmasterv6 
where teamid = ? 
and workoutidv2 = ? 
and actualsplit <> '00:00:00.0' 
group by date 
order by date asc");

这是我得到的

An Athlete      2018-04-29  00:02:01.9  2018-04-30  00:01:59.1
Another Rower   2018-04-29  00:02:00.4  2018-04-30  00:01:56.2
Average         00:02:00.5000           00:01:57.5000

29 号的时间应该平均,30 号的时间应该平均。正如你所看到的,它们有点偏离。

标签: phpmysql

解决方案


推荐阅读