从网站上的另一篇文章中,我进行了以下类型的查询。他们使用总和,我正在寻找列表的计数。
SELECT
COUNT(IF(sold_price < 20,1,0)) as 'Under 20',
COUNT(IF(sold_price BETWEEN 20 and 50,1,0)) as '20 - 50',
COUNT(IF(sold_price BETWEEN 50 and 100,1,0)) as '50 - 100',
COUNT(IF(sold_price BETWEEN 100 and 250,1,0)) as '100 - 250',
COUNT(IF(sold_price BETWEEN 250 and 500,1,0)) as '250 - 500',
COUNT(IF(sold_price BETWEEN 500 and 1000,1,0)) as '500 - 1000',
COUNT(IF(sold_price BETWEEN 1000 and 2000,1,0)) as '1000 - 2000',
COUNT(IF(sold_price > 2000,1,0)) as 'Over 2000'
FROM listings
where current_batch = 'Y'
我所有的结果都以相同的数字返回
Under 20 20 - 50 50 - 100 100 - 250 250 - 500 500 - 1000 1000 - 2000 Over 2000
94665 94665 94665 94665 94665 94665 94665 94665
有没有人对表演有任何建议,或者如果这可以通过计数来完成?