admin_hub

sysop@hub:~/cheat-sheets/sql-window-functions-cheat-sheet$

sql-window-functions-cheat-sheet

A window function calculates over a set of rows and keeps every row, where GROUP BY would collapse them. The examples use a table tickets(id, team, agent, opened_at, closed_at, minutes) and run on PostgreSQL, SQL Server, MySQL 8, MariaDB 10.2 and newer, and SQLite 3.25 and newer.