0
A
回答
2
我假设你真的不想要范围重叠:
count(case when <column> between 0 and 5000 then 1 else null end) as range0,
count(case when <column> between 5001 and 10000 then 1 else null end) as range1,
...
也许你喜欢(如果你真的意味着0〜4999,5000〜9999等):
count(case when <column>/5000 = 0 then 1 else null end) as range0,
count(case when <column>/5000 = 1 then 1 else null end) as range1,
count(case when <column>/5000 = 2 then 1 else null end) as range2,
count(case when <column>/5000 = 3 then 1 else null end) as range3,
count(case when <column>/5000 = 4 then 1 else null end) as range4,
count(case when <column>/5000 = 5 then 1 else null end) as range5
你需要最后一个实际覆盖25,000或只是做>= 4
。并注意我假定了整数除法。
相关问题
- 1. 将一列数据拆分为多列的SQL查询
- 2. SQL将多列拆分为多行
- 3. 将列拆分为多列
- 4. 将列拆分为多列
- 5. 如何将SQL查询返回的值拆分为SQL SERVER中的多个列?
- 6. 需要SQL查询才能将列拆分为3列
- 7. SQL将结果拆分为多个列
- 8. SQL查询的单个列值拆分为多个行
- 9. SQL查询来一列分为两列
- 10. 根据特定列值将SQL列拆分为多列
- 11. 将SQL列中的分隔值拆分为多行
- 12. 将CSV列内容拆分为多列
- 13. 将地址列拆分为多列
- 14. 将列值拆分为多列pandas/python
- 15. 将嵌套列拆分为多列UNIX
- 16. 将列表拆分为多列
- 17. 将单个列拆分为多个列
- 18. 将一列中的数据拆分为多个列
- 19. SQL查询(分类多列)
- 20. Progres - 将查询输出拆分为多列
- 21. 根据列名将查询拆分为多个数组
- 22. 将两列分组为一列的SQL查询
- 23. 一列拆分为更多列的SQL Server 2008?
- 24. 拆分/将一列转换为多行和多列
- 25. 将多个列拆分为多个行
- 26. 如何将SQLite列中的分隔值拆分为多列
- 27. 根据列中的值将SQL表拆分为多个表
- 28. SQL:拆分列值分为两列
- 29. 将一个列中的多个值拆分为多个行R
- 30. 将值拆分到列SQL
啊,案例陈述。我完全忘了这些,谢谢。 – Leon
@Leon:根据您的DBMS,您也可以使用过滤的聚合:例如'count(*)filter(/5000 = 0)' –