MariaDB Window Functions: Replacing Self-Joins for Running Totals and Top-N-Per-Group
MariaDB 10.2+ window functions replace brittle self-joins for running totals and top-N-per-group queries. A worked example shows ROW_NUMBER() and SUM() OVER with explicit framing, plus EXPLAIN checks to catch temporary-table spills before production.