Question: how to do subqueries in hive?
Answer: Subqueries in the FROM Clause Columns in the subquery select list must have unique names. The columns in the subquery select list are available in the outer query just like columns of a table. The subquery can also be a query expression with UNION. Hive supports arbitrary levels of subqueries.