Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add line breaks after SELECT in two examples, expand their explanations (HIVE-4933 & -4934)

...

There can be multiple OVER clauses in a single query. A single OVER clause only applies to the immediately preceding function call. In this example, the first OVER clause applies to COUNT(b) and the second OVER clause applies to SUM(b):

Code Block
languagesql
SELECTSELECT 
 a,
 COUNT(b) OVER (PARTITION BY c),
 SUM(b) OVER (PARTITION BY c)
FROM T;

Aliases can be used as well, with or without the keyword AS:

Code Block
languagesql
SELECTSELECT 
 a,
 COUNT(b) OVER (PARTITION BY c) AS b_count,
 SUM(b) OVER (PARTITION BY c) b_sum
FROM T;

...