In MySQL, the WINDOW
clause is an optional clause that we can use to create a named window. The named window can then be referred to from a window function.
Many SQL developers define their window functions directly in the OVER
clause. But that’s not the only way to do it. We can also define them in a WINDOW
clause, and then refer to them in the OVER
clause.
When we define the window function in a WINDOW
clause, we name it. When we do this, we can refer to that name from the OVER
clause. This eliminates the need to include the definition directly inside the OVER
clause.