mysql 用sum(liezhi)  -->leizhi是time类型。当好像计算出的结果不正确,不知道是怎么回事?

解决方案 »

  1.   

    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多点。、不知是怎么回事?
      

  2.   

    哦,我知道了。mysql漏洞:他那个分钟时乘以100的,不是60.