平均时间值(MySQL) [英] Average time values (MySQL)

查看:80
本文介绍了平均时间值(MySQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个带有ID列的临时表和带有两行数据类型TIME的tTime列:

If I have a MySQL table "tempt" with an ID column and a "tTime" column of data type TIME with two rows:

1, '00:00:45'
2, '00:01:15'



即第1行持有45秒,第2行持有1分15秒。



如果我现在运行以下查询


i.e. row 1 holds 45 seconds and row 2 holds 1 minute and 15 seconds.

If I now run the following query

SELECT AVG(tTime) from tempt



我得到的答案是:


the answer I get is:

80.0000





什么那代表什么?我怎样才能得到我想要的答案(显然是1分钟)..?







好​​吧,我有点慢 - 80是45和115的平均值......但wtf的使用对任何人来说都是这样吗? MySQL如何以及为什么将00:01:15变成115?





好的,所以我必须使用:



What does that represent? And how can I get the answer I am looking for (which is 1 minute, obviously) ..?

[edit]

OK, I'm a bit slow - 80 is the average of 45 and 115... but wtf use is that to anyone? How and why does MySQL turn 00:01:15 into 115?

[edit 2]

ok, so I have to use:

SELECT AVG( 360*HOUR(tTime) + 60*MINUTE(tTime) + SECOND(tTime)) from tempt



以获得答案为止。



Blimey。谢谢MySQL:/


to get the answer ins econds.

Blimey. Thank you MySQL :/

推荐答案

我自己解决了:)

虽然我还是想知道MySQL如何转向00:01: 15到115
Solved it myself :)
Though I'd still like to know how MySQL turns 00:01:15 into 115


这篇关于平均时间值(MySQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆