SQL Window Functions: The Analytics Queries Your ORM Won't Write for You
Running totals, rankings, moving averages, lag and lead comparisons: window functions handle the analytics queries that would otherwise require application-side loops or multiple round-trips. Here's how they work.