Window Function in SQL
Shaique Hossain
1 min read
A window function in SQL performs calculations across a set of table rows related to the current row, without reducing the number of rows returned by the query. It operates within a "window" of rows defined by a specific partition or ordering, specified by the OVER
clause. Common window functions include ROW_NUMBER()
, RANK()
, LEAD()
, and LAG()
, which assign row numbers, rankings, and access values from other rows within the window. Window functions enable advanced analytics like running totals, moving averages, and cumulative sums, enhancing query flexibility and data analysis capabilities in SQL.
0
Subscribe to my newsletter
Read articles from Shaique Hossain directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by