Last active
March 10, 2020 04:22
-
-
Save YiLi225/b7e6225dfbc1d89652ea9b8c1198d190 to your computer and use it in GitHub Desktop.
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
-- 4) Conditional where clause | |
SELECT | |
DAT.ID_VAR, | |
DAT.SEQ_VAR, | |
DAT.NUM_VAR, | |
DATE_VAR1, | |
DATE_VAR2, | |
TRUNC(DATE_VAR2) - TRUNC(DATE_VAR1) AS LAG_IN_DATES | |
FROM | |
CURRENT_TABLE DAT | |
WHERE | |
(TRUNC(DATE_VAR2) - TRUNC(DATE_VAR1)) >= CASE WHEN SEQ_VAR IN (1,2,3) THEN 0 WHEN SEQ_VAR IN (4,5,6) THEN 1 ELSE 2 END | |
ORDER BY ID_VAR, SEQ_VAR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment