选择查询中的号码组
我有一个表,其中保存用户编号及其“分数”。
user_number | score
0832824 6
0478233 3
... ...
分数从 3 到 15。我想创建一个查询来获取分数以及具有该分数的用户总数。但我需要制作四组不同的分数:12 到 15、8 到 11、5 到 7 和小于 5。
有点像这样:
score | total_users
12 to 15 5000
8 to 11 3000
... ...
感谢您提供的任何答案!
I have a table where I keep users numbers and their "score"
user_number | score
0832824 6
0478233 3
... ...
The score goes from 3 to 15. I want to create a query that would fetch the score and the total of users with this score. But I need to make four different groups of score : 12 to 15, 8 to 11, 5 to 7 and less than 5.
Sort of like this :
score | total_users
12 to 15 5000
8 to 11 3000
... ...
Thanks for any answer you can provide!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 BETWEEN 子句单独选择每个组,并使用组合结果UNION
You could select each group individually using a BETWEEN clause and combine the results using a UNION