0
我已經繼承了一個Oracle數據庫並用於MySQL,我正在努力獲取我需要的數據。Oracle - 此功能缺少窗口規範
我想從TTDINV700732和TTCCOM001732中獲取記錄,其中TTDINV700732中的最大(日期)是一年前的GTEQ,而今天的日期是GTEQ的連接表TTDINV150732中有記錄。
我得到的錯誤
[99999][30484] ORA-30484: missing window specification for this function
這裏是我的SQL
SELECT
first_value(trim("TTDINV700732"."T$ITEM")) AS "item",
first_value("TTDINV700732"."T$CWAR") AS "whse",
max("TTDINV700732"."T$TRDT") AS "date",
first_value("TTCCOM001732"."T$NAMB") AS "business"
FROM "DB"."TTDINV700732" "TTDINV700732"
LEFT OUTER JOIN "DB"."TTIITM001732" "TTIITM001732" ON "TTDINV700732"."T$ITEM"="TTIITM001732"."T$ITEM"
LEFT OUTER JOIN "DB"."TTCCOM001732" "TTCCOM001732" ON "TTIITM001732"."T$CPLB"="TTCCOM001732"."T$EMNO"
LEFT OUTER JOIN "DB"."TTDINV150732" "TTDINV150732" ON "TTDINV150732"."T$ITEM"="TTDINV700732"."T$ITEM"
where "TTDINV700732"."T$TRDT" <= to_date('12 Oct 2016', 'DD MON YYYY')
and "TTDINV700732"."T$QUAN" < 0
and "TTDINV150732"."T$DATE" >= to_date('12 Oct 2017','DD MON YYYY')
group by "TTDINV700732"."T$ITEM", "TTDINV700732"."T$CWAR"
在Oracle中'FIRST_VALUE'分析函數只能與一個窗口子句一起使用,例如'FIRST_VALUE OVER(按列逐列分列)'。示例請參閱:https://oracle-base.com/articles/misc/first-value-and-last-value-analytic-functions –