sum()函数计算时间

wudaobugu 2008-07-24 02:53:08
mysql 用sum(liezhi) -->leizhi是time类型。当好像计算出的结果不正确,不知道是怎么回事?
...全文
262 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudaobugu 2008-07-24
  • 打赏
  • 举报
回复
我那有个乱码的问题 一直没有解决,希望大哥帮助看看。
WWWWA 2008-07-24
  • 打赏
  • 举报
回复
呵呵,学到了,没有想到是这个原因
WWWWA 2008-07-24
  • 打赏
  • 举报
回复
简单一点,用5条记录来测试,看看两种方法的结果是否一致
wudaobugu 2008-07-24
  • 打赏
  • 举报
回复
哦,我知道了。mysql漏洞:他那个分钟时乘以100的,不是60.
wudaobugu 2008-07-24
  • 打赏
  • 举报
回复
不知道结果为什么会有偏差?
WWWWA 2008-07-24
  • 打赏
  • 举报
回复
应该按小时、分、秒计算,结果准确一些,没有看到记录
wudaobugu 2008-07-24
  • 打赏
  • 举报
回复
select sum(total_time) from balance_conf_account where start_time>'2007-01-01 00:00:00' and end_time<'2009-01-01 00:00:00
' and end_time!='0000-00-00 00:00:00' and card_index=1;
+-----------------+
| sum(total_time) |
+-----------------+
| 8446 |
+-----------------+
1 row in set
mysql>
select SECOND
(total_time) from balance_conf_account where start_time>'2007-01-01 00:00:00' and end_time<'2009-01-01 00:00:00' and end_time!='0000-00-00 00:00:00' and card_index=1;
+--------------------+
| SECOND(total_time) |
+--------------------+
| 0 |
| 50 |
| 12 |
| 42 |
| 42 |
+--------------------+
5 rows in set
mysql>
select MINUTE
(total_time) from balance_conf_account where start_time>'2007-01-01 00:00:00' and end_time<'2009-01-01 00:00:00' and end_time!='0000-00-00 00:00:00' and card_index=1;
+--------------------+
| MINUTE(total_time) |
+--------------------+
| 43 |
| 20 |
| 10 |
| 10 |
| 0 |
+--------------------+

select HOUR
(total_time) from balance_conf_account where start_time>'2007-01-01 00:00:00' and end_time<'2009-01-01 00:00:00' and end_time!='0000-00-00 00:00:00' and card_index=1;
+------------------+
| HOUR(total_time) |
+------------------+
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
+------------------+
用第一种是8000多秒

第二,第三,第四的总和才5000多点。、不知是怎么回事?
WWWWA 2008-07-24
  • 打赏
  • 举报
回复
计算分钟、小时?将记录及正确结果贴出来看看

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧