SQL aggregate functions
We've covered aggregate functions in the previous chapter, but here's a quick refresher before we compare them with window functions. SQL aggregate functions are functions that perform calculations on a set of values and return an aggregated result after summarization. These functions are used to summarize data within a specified window of rows related to the current row in the result set.
Figure 9.2 – SQL aggregate functions
Some of the most commonly used SQL aggregate functions are as follows:
SUM
: Returns the sum of values for a specified columnAVG
: Returns the average of values for a specified columnMIN
: Returns the minimum value for a specified columnMAX
: Returns the maximum value for a specified columnCOUNT
: Returns the number of rows in a specified window
These aggregate functions can be used in conjunction with a window specification to perform complex calculations and...