Analytical Functions Recap
Analytical Functions Recap
Analytic functions enhance both database performance and developer productivity. They are valuable
for all types of processing, ranging from interactive decision support to batch report jobs.
Ranking Family
This family supports business questions like “show the top 10 and bottom 10 salesperson per each
region” or “show, for each region, salespersons that make up 25% of the sales”.
This family addresses questions like “show the 13-week moving average of a stock price” or “show
cumulative sum of sales per each region.” The new features provide moving and cumulative processing
for all the SQL aggregate functions including AVG, SUM, MIN, MAX, COUNT, VARIANCE and STDDEV
One of the most common types of calculations is the comparison of a non-aggregate value to an
aggregate value. All percent-of-total and market share calculations require this processing. The new
family provides reporting aggregate processing for all SQL functions including AVG, SUM, MIN,MAX,
COUNT, VARIANCE and STDDEV
LAG/LEAD Family
Studying change and variation is at the heart of analysis. Necessarily, this involves comparing the values
of different rows in a table. While this has been possible in SQL, usually through self-joins, it has not
been efficient or easy to formulate. The LAG/LEAD family enables queries to compare different rows of a
table simply by specifying an offset from the current row.
Examples: