Window Functions (EN)

Concept

Functions that operate on a set of rows without grouping them

Definition

Window Functions enable calculations such as moving averages, rankings, and cumulative sums within defined partitions. They operate on a window of rows without grouping them, unlike regular aggregate functions. The correct use of PARTITION BY and ORDER BY clauses is crucial for predictable results. Window Functions are implemented with the OVER clause and are powerful for analytical tasks.

Architecture

flowchart TD   A[Datenquelle] --> B[Fensterdefinition
OVER (PARTITION BY...)] B --> C[Window Function
RANK(), ROW_NUMBER(), etc.] C --> D[Ergebnis mit
berechneten Werten]

Im Kontext

  • Wird typischerweise zusammen mit SQL-Abfragen verwendet
  • Verwandt zu: Aggregatfunktionen, CTEs, Subqueries
  • Beispiel-Einsatz: Berechnung von laufenden Summen oder Rängen in Ergebnis-Tabellen
Quelle: AI Generated