with daily_gmv as (
select date(pay_success_date) as pay_date
                        ,case when sale_channel = 11 then '苹果'
                                                when sale_channel = 12 then '华为'
                                                when sale_channel = 13 then '小米'
                                                when sale_channel = 14 then '荣耀'
                                                when sale_channel = 15 then '应用宝'
                                                when sale_channel = 17 then '魅族'
                                                when sale_channel = 18 then 'VIVO'
                                                when sale_channel = 19 then 'OPPO'
                                                when sale_channel = 21 then '学而思'
                                                when sale_channel = 22 then '讯飞'
                                                when sale_channel = 23 then '步步高'
                                                when sale_channel = 24 then '作业帮'
                                                when sale_channel = 25 then '小度'
                                                when sale_channel = 26 then '希沃'
                                                when sale_channel = 27 then '京东方'
                                                when sale_channel = 41 then '官网'
                                                else '小程序'
                                end as sale_channel
                        ,sum(pay_amount_int)/100 as amount
from bi_vala_order
where sale_channel in (11,12,13,14,15,17,18,19,21,22,23,24,25,26,27,41,71)
and order_status = 3
and pay_amount_int > 49800
and pay_success_date >= '2026-03-04' and pay_success_date < '2026-03-05'
group by pay_success_date
                                ,case when sale_channel = 11 then '苹果'
                                                        when sale_channel = 12 then '华为'
                                                        when sale_channel = 13 then '小米'
                                                        when sale_channel = 14 then '荣耀'
                                                        when sale_channel = 15 then '应用宝'
                                                        when sale_channel = 17 then '魅族'
                                                        when sale_channel = 18 then 'VIVO'
                                                        when sale_channel = 19 then 'OPPO'
                                                        when sale_channel = 21 then '学而思'
                                                        when sale_channel = 22 then '讯飞'
                                                        when sale_channel = 23 then '步步高'
                                                        when sale_channel = 24 then '作业帮'
                                                        when sale_channel = 25 then '小度'
                                                        when sale_channel = 26 then '希沃'
                                                        when sale_channel = 27 then '京东方'
                                                        when sale_channel = 41 then '官网'
                                                        else '小程序'
                                        end
)
select 
    pay_date,
    sale_channel,
    amount,
    round(amount / sum(amount) over (partition by pay_date) * 100, 2) as ratio
from daily_gmv
order by amount desc;