sum列中的mySQL Sum

时间:2017-02-10 07:10:41

标签: mysql

      SELECT tbl_trans.trans_username,
    Sum(Case When tbl_trans.trans_type <> 'REWARD' AND tbl_trans.trans_winlose <> 'QB' then
         trans_winloseamount Else 0 End) BETHOST,
    Sum(Case When tbl_trans.trans_winlose = 'QB'  then
         trans_winloseamount Else 0 End) QB, 
     Sum(Case When tbl_trans.trans_type = 'REWARD'  then
         trans_winloseamount Else 0 End) reward ,
         Sum(sum(BETHOST)+sum(QB)+sum(reward)) totalsum
 FROM tbl_trans 
 GROUP BY trans_username

我需要总计BETHOST,QB和奖励 如何总结这个Sum(sum(BETHOST)+sum(QB)+sum(reward)) totalsum

1 个答案:

答案 0 :(得分:0)

请试试这个

sum(SELECT(BETHOST))+sum(SELECT(QB))+sum(SELECT(reward)) AS totalsum