【发布时间】:2016-10-01 12:06:18
【问题描述】:
我确实有 Mercer_credit_history 表,我在其中存储商家信用、借记和交易类型。
我想根据交易类型对 CREDIT 或 DEBIT 求和。
记录
我试过这个:
选择 SUM(ABS(debit)) 作为 dealer_credit FROM Mercer_credits_history WHERE transaction_type='premium_debit'和merchant_id='x'
联合
SELECT SUM(ABS(credit)) as dealer_margin_earned FROM Mercer_credits_history WHERE transaction_type='margin_credit'和merchant_id='x'
并得到输出
如果我能有更好的查询以及单独的键值对中的值,我将不胜感激
【问题讨论】: