常见的消费区间统计

表结构如下


表结构,红色部分为消费金额
select count(case when ifnull(turnover,0) <500 then id end) as model1
,count(case when ifnull(turnover,0)>=500 and ifnull(turnover,0)<1000 then id end) as model2
,count(case when ifnull(turnover,0)>=1000 and ifnull(turnover,0)<1500 then id end) as model3
,count(case when ifnull(turnover,0)>=1500 and ifnull(turnover,0)<2000 then id end) as model4
,count(case when ifnull(turnover,0)>=2000 and ifnull(turnover,0)<3000 then id end) as model5
,count(case when ifnull(turnover,0)>=3000 and ifnull(turnover,0)<5000 then id end) as model6
,count(case when ifnull(turnover,0)>=5000 and ifnull(turnover,0)<8000 then id end) as model7
,count(case when ifnull(turnover,0)>=8000 and ifnull(turnover,0)<10000 then id end) as model7
,count(case when ifnull(turnover,0)>=10000 then id end) as model8 
from vet_rundata

结果集


查询结果集

你可能感兴趣的:(常见的消费区间统计)