10

I do understand window functions and group by separately.

But what happens when you use both a window function and a group by clause in the same query ?

  • Are the selected rows grouped first, then considered by the window function ?
  • Or does the window function executes first, then the resulting values are grouped by group by ?
  • Something else ?
Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236

1 Answers1

15

Quote from the manual:

If the query contains any window functions, these functions are evaluated after any grouping, aggregation, and HAVING filtering is performed

emphasis mine