Window Function Descriptions For information about optimization and window functions, see Section 8.2.1.21, “Window Function Optimization” . This section describes nonaggregate window functions that, for each row from a query, perform a calculation using rows related to that row. Most aggregate functions also can be used as window functions; see Section 12.20.1, “Aggregate Function Descriptions” . For window function usage information and examples, and definitions of terms such as the  OVER  clause, window, partition, frame, and peer, see Section 12.21.2, “Window Function Concepts and Syntax” . In the following function descriptions,  over_clause  represents the  OVER  clause, described in Section 12.21.2, “Window Function Concepts and Syntax” . Some window functions permit a null_treatment  clause that specifies how to handle  NULL  values when calculating results. This clause is optional. It is part of the SQL standard, but the MySQL implementation permits only  RESPECT NULLS (which is also the default). This means that  NULL  values are considered when calculating results.  IGNORE NULLS  is parsed, but produces an error. Returns the cumulative distribution of a value within a group of values; that is, the percentage of partition values less than or equal to the value in the current row. This represents the number of rows preceding or peer with the current row in the window ordering of the window partition divided by the total number of rows in the window partition. Return values range from 0 to 1. This function should be used with  ORDER BY  to sort partition rows into the desired order. Without  ORDER BY , all rows are peers and have value  N / N  = 1, where  N  is the partition size. over_clause  is as described in Section 12.21.2, “Window Function Concepts and Syntax” . The following query shows, for the set of values in the  val  column, the  CUME_DIST()  value for each row, as well as the percentage rank value returned by the similar  PERCENT_RANK()  function. For reference, the query also displays row numbers using  ROW_NUMBER() : 2418 12.21.1 Window Function Descriptions Table 12.26 Window Functions Name Description CUME_DIST() Cumulative distribution value DENSE_RANK() Rank of current row within its partition, without gaps FIRST_VALUE() Value of argument from first row of window frame LAG() Value of argument from row lagging current row within partition LAST_VALUE() Value of argument from last row of window frame LEAD() Value of argument from row leading current row within partition NTH_VALUE() Value of argument from N-th row of window frame NTILE() Bucket number of current row within its partition. PERCENT_RANK() Percentage rank value RANK() Rank of current row within its partition, with gaps ROW_NUMBER() Number of current row within its partition • CUME_DIST() over_clause