Skip to content

Instantly share code, notes, and snippets.

@ldenson11
Last active October 25, 2019 21:25
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/a5f3ad54b67494e89026972e3527198e to your computer and use it in GitHub Desktop.
Save ldenson11/a5f3ad54b67494e89026972e3527198e to your computer and use it in GitHub Desktop.
-- detect multiple auths in a short window and
-- send to lock account topic/microservice
SELECT card,
MAX(amount) as theamount,
TUMBLE_END(eventTimestamp, interval '5' minute) as ts
FROM payments
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