select count(*),sum(if(amount<=10,1,0)as `数量小于10`,sum(if(amount>10 and amount<=20,1,0)as `数量小于20大于10`
from orders;
统计总客户数,和销量在(0,10]的客户数,(10,20]的客户数
所用表orders为
Company | amount |
---|---|
Ajjhd | 2 |
Daljj | 12 |
Rajs | 9 |
Fghsd | 14 |
… | … |
select count(*),sum(if(amount<=10,1,0)as `数量小于10`,sum(if(amount>10 and amount<=20,1,0)as `数量小于20大于10`
from orders;
统计总客户数,和销量在(0,10]的客户数,(10,20]的客户数
所用表orders为
Company | amount |
---|---|
Ajjhd | 2 |
Daljj | 12 |
Rajs | 9 |
Fghsd | 14 |
… | … |