我试图从同一个表中获取匹配和不匹配的值,但是它给出了double值这是我的查询
select
sum(pp.redeem_points_used) as OnlineRewards,
sum(pp1.redeem_points_used) as GlocalRewards,
pp.user_details_id
from
panalist_redeem_points as pp,
panalist_redeem_points as pp1
where
pp.transaction_id not like 'G%' and pp1.transaction_id like 'G%'
group by pp.transaction_id;
答案 0 :(得分:0)
只需选择一个表格即可完成此操作:
select
sum((pp.transaction_id not like 'G%')*pp.redeem_points_used) as OnlineRewards,
sum((pp.transaction_id like 'G%')*pp.redeem_points_used) as GlocalRewards,
pp.user_details_id
from
panalist_redeem_points as pp
group by pp.transaction_id;