Last active
March 13, 2020 14:53
-
-
Save ldenson11/e088b09e680e68e35c6b5c67e410ad93 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
-- production fraud and alerting job | |
SELECT * | |
FROM paymentauths | |
MATCH_RECOGNIZE( | |
PARTITION BY card | |
ORDER BY eventTimestamp | |
MEASURES | |
F.amount AS first_amount, | |
E.amount AS last_amount | |
ONE ROW PER MATCH | |
AFTER MATCH SKIP PAST LAST ROW | |
PATTERN (F+ E) -- match 1 or more rows | |
DEFINE | |
F AS F.amount IS NOT NULL AND F.amount > 10, -- lower boundary | |
E AS E.amount IS NOT NULL AND F.amount < E.amount) -- starting value less than ending value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment