WINDOW FUNCTION MAX

description

The LEAD() method is used to calculate the maximum value within the window.

1. MAX([DISTINCT | ALL] expression) [OVER (analytic_clause)]

example

Calculate the maximum value from the first row to the row after the current row

1. select x, property,
2. max(x) over
3. (
4. order by property, x
5. rows between unbounded preceding and 1 following
6. ) as 'local maximum'
7. from int_t where property in ('prime','square');

9. | x | property | local maximum |
10. |---|----------|---------------|
11. | 2 | prime    | 3             |
12. | 3 | prime    | 5             |
13. | 5 | prime    | 7             |
14. | 7 | prime    | 7             |
15. | 1 | square   | 7             |
16. | 4 | square   | 9             |
17. | 9 | square   | 9             |

keywords

1. WINDOW,FUNCTION,MAX