[英]Where do windowed functions lay in sql's order of operations?
I am looking for at what point do windowed functions happen in sql. 我正在寻找窗口函数在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
我知道它们可以在
SELECT
和ORDER BY
子句中使用,所以我倾向于认为它们发生在ORDER BY
,但在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. SQL Server公布查询的逻辑处理 。 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. FROM
, WHERE
, GROUP BY
和HAVING
子句之后。 ORDER BY
(even if you use order by (select null))
). ORDER BY
无关(即使您使用order by (select null))
)也是如此。 TOP
does not affect the processing. TOP
不会影响处理。 SELECT DISTINCT
. SELECT DISTINCT
之前进行。 I think the conclusion is that they are parsed in the SELECT
or ORDER BY
as with other expressions in those clauses. 我认为结论是,它们与这些子句中的其他表达式一样,在
SELECT
或ORDER BY
中进行了解析。 There is no separate place for them. 他们没有单独的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.