sum 统计 SQL 实例

select sum(temp.times),sum(temp.c) from (select
      t.work_id releaserWorkId,
      t.real_name releaserName,
      t.nick_name releaserNickName,
      count(1) c,
      round(ifnull(sum(t.times),0),2) times
    from commonwealtime t
    where t.state = 0 and t.isdel=0
    AND gmt_create BETWEEN '2017-04-01'
    AND '2018-03-31 23:59:59'
    group by t.work_id
    order by times desc) temp;
    原文作者:一个会写诗的程序员
    原文地址: https://www.jianshu.com/p/c6476d489483
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞