我正在寻找在Redshift中使用的一些窗口函数中的一些窗口。
到目前为止,这是我的SQL:
WITH cte AS (
SELECT id
, total
, COUNT (id) OVER() AS count_orders
, SUM(total) OVER(ORDER BY period_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_total
FROM orders
)
SELECT id
, total
, count_orders
, running_total
, NTILE (4) OVER ntile_window AS quartile
, NTILE (5) OVER ntile_window AS quintile
FROM cte
WINDOW ntile_window AS (ORDER BY running_total)
我收到的错误消息是:
错误:“ntile_window”处或附近的语法错误行:13位置:24
它似乎没有运行,是否有人知道AWS是否支持窗口别名?或者我哪里错了?
非常感谢