我正在尝试编写一个查询,该查询返回其价格落入certrain存储桶的商品的计数:
例如,如果我的表是:
item_name | price
i1 | 2
i2 | 12
i3 | 4
i4 | 16
i5 | 6
输出:
range | number of item
0 - 10 | 3
10 - 20 | 2
到目前为止,我这样做的方式是
SELECT count(*)
FROM my_table
Where price >=0
and price <10
然后
SELECT count(*)
FROM my_table
Where price >=10
and price <20
然后将每次粘贴的结果复制到excel中。
有没有一种在sql查询中自动执行此操作的方法?
https://stackoverflow.com/questions/6669730
复制相似问题