Introduction
Window functions help us calculate values across rows related to the current row without losing the row's details. They make it easy to do running totals, ranks, and averages within groups.
When you want to find the rank of each student in a class without grouping all students into one row.
When you need a running total of sales for each day but still want to see each day's sales separately.
When you want to compare each employee's salary to the average salary in their department.
When you want to find the difference between a row's value and the previous row's value in a list.
When you want to calculate moving averages or cumulative sums in a report.