gpt4 book ai didi

hadoop - 在配置单元 mapreduce 中计算 desc

转载 作者:可可西里 更新时间:2023-11-01 16:42:18 24 4
gpt4 key购买 nike

我在配置单元中有一个表,它包含

questionid,questiontag,answerID,userIDofanswerer 

我需要此数据集中最常用的前 10 个标签。

我试过了:

select count(questionID),questiontag from table GROUP BY tags;

但我如何按 Count(questionID)

排序

最佳答案

在下面的查询中,ORDER BY cnt DESC LIMIT 10 将选择前 10 个最常用的标签:

    SELECT count(questionID) cnt ,
questiontag
FROM table
GROUP BY questiontag
ORDER BY cnt DESC
LIMIT 10;

count(*) 将计算所有行,包括 NULL questionID

count(questionID) 将只计算 questionID 不为 NULL 的行

关于hadoop - 在配置单元 mapreduce 中计算 desc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39753845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com