I am looking for at what point do windowed functions happen in sql. I know they can be used in the SELECT
and ORDER BY
clauses, so I am inclined to think they happen after ORDER BY
, but before TOP
Window functions happen when the optimizer decides that they should happen. This is best understood looking at the query plan.
SQL Server advertises the logical processing of queries. This is used to explaining scoping rules (in particular). It is not related to how the query is actually executed.
Clearly, the rules for window functions are:
FROM
, WHERE
, GROUP BY
, and HAVING
clauses are processed. ORDER BY
(even if you use order by (select null))
). TOP
does not affect the processing. SELECT DISTINCT
. I think the conclusion is that they are parsed in the SELECT
or ORDER BY
as with other expressions in those clauses. There is no separate place for them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.