Oracle Model Clause

如此相信發表於2022-03-09

SELECT country,prod, YEAR,sales FROM sales_view WHERE country IN ('Italy','Japan')
MODEL  RETURN UPDATED ROWS
PARTITION BY (country)
DIMENSION BY (prod, YEAR)
MEASURES (sale sales)
RULES(
 sales['Bounce',2002] = sales['Bounce',2001] + sales['Bounce',2000],
 sales['Y Box',2002] = sales['Y Box',2001],
 sales['2_Products',2002] = sales['Bounce',2002] + sales['Y Box',2002],
 sales['2_Products',2003] = 2*sales['2_Products',2002]
)
ORDER BY country, prod, YEAR;

其中紅色的部分是可選的。
partition與分析函式中的partition相似,而dimension可以看成是excel中的行與列的值。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70014873/viewspace-2868069/,如需轉載,請註明出處,否則將追究法律責任。

相關文章