美文网首页
mysql condition sum

mysql condition sum

作者: 拾大花sdf | 来源:发表于2017-09-30 10:19 被阅读0次

    select abs(sum(Case When b.return_type = 2
    Then b.box_count Else 0 End)) as collect_count,
    sum(Case When b.return_type=0
    Then b.box_count Else 0 End) as return_count,
    sum(Case When b.return_type=1
    Then b.box_count Else 0 End) as in_count
    ,r.name,r.tel from box_records as b inner join roles as r on b.role_id=r.id
    group by b.role_id;

    相关文章

      网友评论

          本文标题:mysql condition sum

          本文链接:https://www.haomeiwen.com/subject/cbjgextx.html