Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Analytical Functions
 

The MODEL statement does calculations on a column in a row based on other rows in a result set

The MODEL or SPREADSHEET clause is very much like treating the result set of a query as a multidimensional array. The keywords MODEL and SPREADSHEET are synonymous. The MODEL or SPREADSHEET clause allows us to compute a row in the result set that can retrieve data on some other row(s) without explicitly defining a virtual table. The overall syntax for the MODEL or SPREADSHEET SQL statement <prior clauses of SELECT statement> MODEL [main] [reference models] [PARTITION BY (<cols>)] DIMENSION BY (<cols>) MEASURES (<cols>) [IGNORE NAV] | [KEEP NAV] [RULES [UPSERT | UPDATE] [AUTOMATIC ORDER | SEQUENTIAL ORDER] [ITERATE (n) [UNTIL <condition>] ] ( <cell_assignment> = <expression> ... )