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

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

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

1、按照等级分类,求不同等级下的创作者数量 with aaa as ( select count(x.author_id) as count_aid, y.author_level from answer_tb x join author_tb y on x.author_id = y.author_id where char_len >= 100 group by 2 ) 3、不同等级数量求和,用2个union就可以啦,虽然代码有点长,不过好理解,也有其他的做法~ select

from ( select '5-6级', sum(count_aid) as ww from aaa where aaa.author_level in (5, 6) union all select '1-2级', sum(count_aid) as ww from aaa where aaa.author_level in (1, 2) union all select '3-4级', sum(count_aid) as ww from aaa where aaa.author_level in (3, 4) order by 2 desc ) as gg where gg.ww!=0

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务