Simple Windowing Function

May 12, 2016
By Bounteous
SELECT
  LAG(num) OVER (ORDER BY num) AS ordered_lag,
  LAG(num) OVER () AS lag,
  num,
  LEAD(num) OVER () AS lead,
  LEAD(num) OVER (ORDER BY num) AS ordered_lead,
FROM 
  ( SELECT 2 AS num),
  ( SELECT 4 AS num),
  ( SELECT 3 AS num),
  ( SELECT 1 AS num),