Sql分组查询,按照不同的类型进行分组统计,把纵向显示的结果变成横向显示

create table Pay
([充值编号] varchar(10),[充值类型] varchar(10),[充值金额] int)
insert into Pay
select '1','微信',5
union all select '2','支付宝',6
union all select '3','微信',3
union all select '4','支付宝',4

表数据:
充值编号 充值类型 金额


1 微信 5
2 支付宝 6
3 微信 3
4 支付宝 4

结果:
微信(充值) 支付宝 (充值) 总金额


     9                         10                   19

楼主这是要问啥?sql? 应该不是吧?

 select  sum(case when 充值类型='微信' then 充值金额 else 0 end)  as '微信',
 sum(case when 充值类型='支付宝' then 充值金额 else 0 end)  as '支付宝',
 sum(充值金额)  as '总金额',
 from pay