HiveSQLException:无法识别'SELECT''MAX''附近的输入(''在表达式规范

时间:2017-05-15 23:59:13

标签: hadoop hive greatest-n-per-group hiveql

我正在尝试获取计数的最大值。代码如下

SELECT coachID, COUNT(coachID)
FROM coaches_awards GROUP BY coachID
HAVING COUNT(coachID) = 
(
   SELECT MAX(t2.awards)
    FROM (
             SELECT coachID, count(coachID) as awards
             FROM coaches_awards
             GROUP BY coachID
          ) t2
);

然而有些事情一直在失败。内部查询工作并给出我想要的答案,如果内部查询被所需的数字替换,则外部查询将起作用。所以我假设我犯了一些语法错误。

我哪里错了?

1 个答案:

答案 0 :(得分:0)

如果您只想找一行,为什么不这样做:

<script src="https://d3js.org/d3.v4.min.js"></script>
<svg width="300" height="200"></svg>

如果您想要关联,请使用SELECT coachID, COUNT(coachID) as cnt FROM coaches_awards GROUP BY coachID ORDER BY cnt DESC LIMIT 1; RANK()

DENSE_RANK()