WINDOW FUNCTION MAX

description

LEAD() 方法用来计算窗口内的最大值。

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

example

计算从第一行到当前行之后一行的最大值

  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');
  8. | x | property | local maximum |
  9. |---|----------|---------------|
  10. | 2 | prime | 3 |
  11. | 3 | prime | 5 |
  12. | 5 | prime | 7 |
  13. | 7 | prime | 7 |
  14. | 1 | square | 7 |
  15. | 4 | square | 9 |
  16. | 9 | square | 9 |

keywords

  1. WINDOW,FUNCTION,MAX