user3322168
user3322168

Reputation: 1

how to use subquery with aggregate function in hive

SELECT peridle, CPU
FROM (SELECT MAX(peridle) FROM try2);

While executing this query in hive I am getting following error

Parse Error: line 1:47 cannot recognize input near 'select' 'MAX' '(' in expression specification

Please suggest a solution how to use aggregate functions in hive subquery

Upvotes: 0

Views: 1146

Answers (1)

Jeremy Beard
Jeremy Beard

Reputation: 2725

At least two things need to be fixed here:

  1. You are not returning fields named peridle or CPU from the sub-query, yet you are trying to select them.
  2. Hive requires you to alias all sub-queries, even if you don't reference the alias. You can quickly do this by changing the ); at the end to ) x; (or however you want to call it).

Upvotes: 1

Related Questions