有没有办法在teradata中重用一个窗口?

时间:2015-06-29 04:43:16

标签: sql teradata

我想在单个查询中多次重复使用相同的窗口定义。

Postgres这样做:

SELECT sum(salary) OVER w, avg(salary) OVER w
FROM empsalary
WINDOW w AS (PARTITION BY depname ORDER BY salary DESC);

teradata是否具有相同的功能?

1 个答案:

答案 0 :(得分:2)

在TD中没有等效的窗函数,你必须每次都写窗口

SELECT sum(salary) OVER (PARTITION BY depname ORDER BY salary DESC), avg(salary) OVER (PARTITION BY depname ORDER BY salary DESC)
FROM empsalary;

有关窗口功能的一些文档:

http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1145_111A/Ordered_Analytical_Functions.083.013.html

http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1145_111A/Ordered_Analytical_Functions.083.012.html#ww1271958