過去兩天我一直在查看這段代碼,但我似乎無法讓它作業。不過,它確實可以在沒有 Window 子句的情況下作業。
它不斷給我:
ORA-00907: missing right parenthesis.
select P.*,
first_value(product_name) over (w) MAX_PRICE,
Last_value(product_name) over (w) MIN_PRICE
from product P
window w as (
partition by product_category
order by price desc
range between unbounded preceding and unbounded following
);
uj5u.com熱心網友回復:
window 子句進入分析函式內部:
select P.*,
first_value(product_name) over (
partition by product_category
order by price desc
range between unbounded preceding and unbounded following
) AS MAX_PRICE,
Last_value(product_name) over (
partition by product_category
order by price desc
range between unbounded preceding and unbounded following
) MIN_PRICE
from product p;
或者,從 Oracle 21 開始,您可以使用:
select P.*,
first_value(product_name) over w AS MAX_PRICE,
Last_value(product_name) over w AS MIN_PRICE
from product p
window w as (
partition by product_category
order by price desc
range between unbounded preceding and unbounded following
)
(分析函式中視窗周圍沒有括號。)
db<>在這里擺弄
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/488350.html
