The window functions are used with the clause. They may appear only in the SELECT
list, or the ORDER BY
clause of a query.
Firebird window functions may be partitioned and ordered.
Syntax
Table 10.1 Window Function Arguments
10.1 Aggregate Functions as Window Functions
All — including FILTER
clause — can be used as window functions, by adding the clause.
A normal query could achieve this, as follows:
Results
The query is repetitive and lengthy to run, especially if EMPLOYEE
happens to be a complex view.
The same query could be specified in a much faster and more elegant way using a window function:
Here, sum(salary) over ()
is computed with the sum of all SALARY
from the query (the table).