对不?????? Select sp.日期,充值档位,购买物品 as ‘物品名称’ ,count(购买物品) as ‘数量’  from src_prepaid sp , (Select id,日期,(case when total>0 and total <=100 then‘(0,100]’                When total<=500 then ‘(100,500]’                When total<=1000 then ‘(500,1000]’                 Else  ‘(1000,inf)’ end) as  ‘充值档位’ from (select id ,日期,sum(充值) as total from scr_prepaid where  时间<日期 and 时间>=date_sub(日期,interval 30 day)  group by id) a ) aa  where aa.id=sp.id and aa.日期=sp.日期 And sp.日期 between ‘2019-08-15’  and  ‘2019-08-20’  group by sp.日期,充值档位,物品名称

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务