select change_type as change_type, sum(points1) as points from (select DECODE(p.change_type, 1, ' 兑换商品', 2, '兑换优惠券', 3, '订单获得', 4, '评价获得', 5, '注册获得', 6, '人工增加', 7, '订单退还', 8, '订单取消退回', 9, '邮箱验证', 10, '评价获得', 11, '评价获得', 12, '评价获得', 13, '评价获得', 15, '抵现消费', 16, '积分过期', 20, '签到', 29, '门店消费', 30, '账户合并', null) as change_type, sum(p.points) as points1 from member_points_his p where 1 = 1 group by change_type) where change_type is not null group by change_type
注意:
在页面展示的时候,sum函数之后要有as 字段 这一步,否则回报列名无效的错误
select change_type1 as change_type, sum(points1) as points from (select DECODE(p.change_type, 1, ' 兑换商品', 2, '兑换优惠券', 3, '订单获得', 4, '评价获得', 5, '注册获得', 6, '人工增加', 7, '订单退还', 8, '订单取消退回', 9, '邮箱验证', 10, '评价获得', 11, '评价获得', 12, '评价获得', 13, '评价获得', 15, '抵现消费', 16, '积分过期', 20, '签到', 29, '门店消费', 30, '账户合并', null) as change_type1, sum(p.points) as points1 from member_points_his p where 1 = 1 group by change_type) where change_type1 is not null group by change_type1