zoukankan      html  css  js  c++  java
  • mysql case when * else end

    分条件计算总数

    SELECT  
       -- SUM(case when TransactionType='账户支出' then AmoutPrice else 0 END) as am,
       -- SUM(case when TransactionType='在线支出' then OnlinePrice else 0 END) as om ,
       -- SUM(case when TransactionType='账户+在线' then price else 0 END) as aom ,
       -- SUM(case when PayPlatform=100 then AmoutPrice else 0 END) as aaom ,
       SUM(case when PayPlatform=1 then OnlinePrice else 0 END) as pam,
       SUM(case when PayPlatform=2 then OnlinePrice else 0 END) as wom ,   
       SUM(case when Type='购买版权' then price else 0 END) as bm,
       SUM(case when Type='PVMode' then price else 0 END) as sm ,
       SUM(Price)as allm
    
    
    from us_c c INNER JOIN us_s u on c.UserId=u.Id 
    where u.UserState<>2 AND c.AddTime>'2017-5-5' and c.AddTime<'2017-8-18' ORDER BY c.AddTime DESC;
  • 相关阅读:
    推箱子
    为textarea增加maxlength属性(转)
    validate
    keypress
    Knockout
    &amp; replace &
    银联参数
    chinapay
    model binding
    JSON.stringify
  • 原文地址:https://www.cnblogs.com/xiaoyaodijun/p/7390986.html
Copyright © 2011-2022 走看看