Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wrong window specification for LEAD and LAG

...

Code Block
sql
sql
SELECT a, LEAD(a) OVER (PARTITION BY b ORDER BY C ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING)
FROM T;

LAG specifying a lag of 3 rows and default value of 0

Code Block
sql
sql
SELECT a, LAG(a, 3, 0) OVER (PARTITION BY b ORDER BY C ROWS 3 PRECEDING)
FROM T;

Distinct counting for each partition

...