Oracle’s Window Syntax

Oracle’s window function syntax is as follows:

FUNCTION_NAME(expr) OVER (window_clause)
window_clause ::= [partitioning] [ordering [framing]]
partitioning ::= PARTITION BY value[, value...]
ordering ::= ORDER [SIBLINGS] BY rule[, rule...]
rule ::= {value | position | alias} [ASC | DESC]
          [NULLS {FIRST | LAST}]
framing ::= {ROWS | RANGE} {not_range | begin AND end}
not_range ::= {UNBOUNDED PRECEDING |
               CURRENT ROW |
               value PRECEDING}
begin ::= {UNBOUNDED PRECEDING |
           CURRENT ROW |
           value {PRECEDING | FOLLOWING}}
end ::= {UNBOUNDED FOLLOWING |
         CURRENT ROW |
         value {PRECEDING | FOLLOWING}}

Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.