|16.25.1.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>
[PARTITION BY (<cols>)]
DIMENSION BY (<cols>)
[IGNORE NAV] | [KEEP NAV]
[UPSERT | UPDATE]
[AUTOMATIC ORDER | SEQUENTIAL ORDER]
[ITERATE (n) [UNTIL <condition>] ]
( <cell_assignment> = <expression> ... )