サイトの別の投稿から、次のタイプのクエリを取得しました。彼らは合計を使用していました。リストの数を探しています。
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
これを行うためのショーに関する提案はありますか、またはこれがカウントで実行できるかどうかはありますか?