Database Reference
In-Depth Information
Window Functions
Window functions are built-in functions provided by PostgreSQL. They are used for
calculation between multiple rows, which are related to the current query row.
Let's start to play around with the various window functions.
In this chapter, we will discuss the following topics:
• How the window functions are in conjunction with the aggregate functions
• The scope, structure, and usage of the window functions with examples
• What each window function is for
Understanding window functions
Window functions are used to perform advance sorting and limit the number of
rows returned on a subset of a joined table of data. We will look at cume_dist() ,
row_number() , rank() , dense_rank() , present_rank() , first_value() , last_
value() , nth_value() , ntile() , lag() and lead() built-in window functions.
User-deined aggregate functions can also act as window functions by calling the
OVER keyword. In this chapter, you will learn only about the PostgreSQL built-in
window function.
We have 11 window functions; we will see each of the 11 functions in the
following sections.
Search WWH ::




Custom Search