-1
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
我需要totalsum BETHOST,QB和獎勵
如何總結這Sum(sum(BETHOST)+sum(QB)+sum(reward)) totalsum
MySQL的總和之列
在相同的結果,上述查詢或一個彙總行? – GurV
@GurV在相同的結果,相同的查詢 –
請參閱http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-是-A-極簡單的SQL查詢 – Strawberry