题解 | #某乎问答高质量的回答中用户属于各级别的数量#

某乎问答高质量的回答中用户属于各级别的数量

http://www.nowcoder.com/practice/69c85db3e59245efb7cee51996fe2273

此题共包含两张表:

表1:answer_tb 表2:author_tb

要解决的问题:

回答字数大于等于100字的认为是高质量回答,请你统计某乎问答高质量的回答中用户属于1-2级、3-4级、5-6级的数量分别是多少,按数量降序排列

解题思路:

  1. 根据用户所属成绩划分level_cnt
  2. 筛选回答数大于100的用户
  3. 以level_cnt分组, num排序

SELECT case when author_level BETWEEN 1 and 2 then '1-2级'
			when author_level BETWEEN 3 and 4 then '3-4级'
			when author_level BETWEEN 5 and 6 then '5-6级'
			end level_cnt,
			count(answer_tb.author_id) num
from author_tb join answer_tb
on author_tb.author_id = answer_tb.author_id
where char_len >= 100
group by level_cnt
ORDER BY num desc

全部评论

相关推荐

点赞 评论 收藏
分享
仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务