这类似于 MYSQL,并且无法理解为什么我无法在窗口函数中同时使用 SUM 和 POWER。特别是 SUM(POWER("DELTA"... 行抛出以下错误:
SQL compilation error: Window function [AVG(CAST(VALUE AS NUMBER(38,3))) OVER (PARTITION BY ID)] may not be nested inside another window function.
删除此行或将其移至第二个 select 语句可修复错误,并且所有其他 . 我认为这是我对 SQL 的一个更基本的误解。任何想法将不胜感激!
WITH UTILS AS (
SELECT
ID,
VALUE AS "TEMP_CELSIUS,
AVG(VALUE) OVER(PARTITION BY ID) AS "TEMP_AVG",
VAR_POP(VALUE) OVER(PARTITION BY ID) As "TEMP_VAR",
STDDEV_POP(VALUE) OVER(PARTITION BY ID) As "TEMP_STD",
COUNT(VALUE) OVER(PARTITION BY ID) As "DEVICE_N",
(VALUE-"TEMP_AVG") AS "DELTA",
SUM(POWER("DELTA", 3)) OVER(PARTITION BY ID) AS "SKEW2"
FROM
TABLE1
)
SELECT
"SKEW2"
FROM
UTILS