FIRST_VALUE(year) OVER (w ORDER BY year ASC) AS first, FIRST_VALUE(year) OVER (w ORDER BY year DESC) AS last FROM sales WINDOW w AS (PARTITION BY country); 

An OVER  clause can only add properties to a named window, not modify them. If the named window definition includes a partitioning, ordering, or framing property, the OVER  clause that refers to the window name cannot also include the same kind of property or an error occurs: 

•This construct is permitted because the window definition and the referring OVER  clause do not contain the same kind of properties: 

OVER (w ORDER BY country) ... WINDOW w AS (PARTITION BY country) 

•This construct is not permitted because the OVER  clause specifies PARTITION BY  for a named window that already has PARTITION BY : 

OVER (w PARTITION BY year) ... WINDOW w AS (PARTITION BY country) 

The definition of a named window can itself begin with a window_name . In such cases, forward and backward references are permitted, but not cycles: 

## 12.21.5 Window Function Restrictions 

•This is permitted; it contains forward and backward references but no cycles: 

WINDOW w1 AS (w2), w2 AS (), w3 AS (w1) 

•This is not permitted because it contains a cycle: 

WINDOW w1 AS (w2), w2 AS (w3), w3 AS (w1) 

The SQL standard imposes a constraint on window functions that they cannot be used in UPDATE  or DELETE  statements to update rows. Using such functions in a subquery of these statements (to select rows) is permitted. 

MySQL does not support these window function features: 

• DISTINCT  syntax for aggregate window functions. 

•Nested window functions. 

•Dynamic frame endpoints that depend on the value of the current row. 

The parser recognizes these window constructs which nevertheless are not supported: 

•The GROUPS  frame units specifier is parsed, but produces an error. Only ROWS  and RANGE  are supported. 

•The EXCLUDE  clause for frame specification is parsed, but produces an error. 

• IGNORE NULLS  is parsed, but produces an error. Only RESPECT NULLS  is supported. 

## 12.22 Performance Schema Functions 

• FROM LAST  is parsed, but produces an error. Only FROM FIRST  is supported. 

