Skip to content

Instantly share code, notes, and snippets.

@ldenson11
Created January 29, 2020 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldenson11/19dc1d9640edf4bd25ae0be184621120 to your computer and use it in GitHub Desktop.
Save ldenson11/19dc1d9640edf4bd25ae0be184621120 to your computer and use it in GitHub Desktop.
-- detect multiple auths in a short window
-- send to alerting framework
SELECT card,
MAX(amount) as theamount,
TUMBLE_END(eventTimestamp, interval '5' minute) as ts
FROM auths
WHERE lat IS NOT NULL
AND lon IS NOT NULL
GROUP BY card, TUMBLE(eventTimestamp, interval '5' minute)
HAVING COUNT(*) > 4 -- >4==fraud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment