Created
March 19, 2018 17:17
-
-
Save barsbek/2a498941f9fd7c5de082a2c210bd40ac to your computer and use it in GitHub Desktop.
postgresql: set frame's range in window function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select count(*) over(order by id rows between unbounded preceding and unbounded following); -- all rows in partition | |
select count(*) over(order by id rows between 2 preceding and 1 following); -- 2 rows before, current and next row | |
select count(*) over(order by id rows unbounded preceding); -- all rows before current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment