Last active
November 11, 2019 13:34
-
-
Save aykononov/e243b22da756b0af81eba75640567e34 to your computer and use it in GitHub Desktop.
LAG и LEAD аналитические функции
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Выводит предыдущее, текущее и последующее значение даты */ | |
WITH t AS (SELECT TRUNC(SYSDATE-1) + LEVEL sdate FROM dual CONNECT BY LEVEL <= 10 ORDER BY TRUNC(SYSDATE)) | |
SELECT | |
LAG(t.sdate) OVER(ORDER BY t.sdate) prev_date | |
,t.sdate | |
,LEAD(t.sdate) OVER(ORDER BY t.sdate) next_date | |
FROM t; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment