排序呢?
我在hive中有一个表,包含
questionid,questiontag,answerID,userIDofanswerer
我需要这个数据集中最常用的10个标签。
I tried:
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的所有行
count(questionID)
将只计算questionID不为NULL的行
try below
select count(questionID) as cnt,questiontag from table GROUP BY questiontag
order by cnt desc limit 10;