Why doesn't LAST_VALUE return the last value?

前端 未结 3 462
盖世英雄少女心
盖世英雄少女心 2021-02-01 10:29

I want to find the last value of y over an ordered partition using a query like this:

SELECT
  x,
  LAST_VALUE(y) OVER (PARTITION BY x ORDER BY y AS         


        
3条回答
  •  时光取名叫无心
    2021-02-01 10:55

    Other option you have is to change the query order by to desc

    SELECT
      x,
      LAST_VALUE(y) OVER (PARTITION BY x ORDER BY y ASC)
    FROM table
    order by x desc
    

    but the you will get the last value only for the first row

提交回复
热议问题