在配置单元 mapreduce 中计算 desc

counting desc in hive mapreduce

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

questionid,questiontag,answerID,userIDofanswerer 

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

我试过了:

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

但我如何通过 Count(questionID)

订购

试试下面

select count(questionID) as cnt,questiontag from table GROUP BY questiontag
order by cnt desc limit 10;

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

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

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

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

的行