Skip to content

Query the values before the specified line in a window and return the default value if no value is available

Use the lag function to query the values before the specified line in a window and return the default value if no value is available.

SQL
* |
select
  __time__,
  lag(streamValue,0,111) over(
    PARTITION BY streamValue
    order by
      status desc
  ) as sallary_rank
order by
  streamValue,
  sallary_rank