Explore Library
Databases & SQLWindow Functions

32 items

Quiz

Leak-Free Running Average Feature

Building a prior-only running average feature per customer without leaking the current or future rows.

For a fraud model you need a feature equal to the average of all of a customer's PRIOR transaction amounts (strictly before the current row, ordered by txn_time), so the current transaction's own amount never leaks into its feature. Which expression computes this correctly?