Write SQL window functions for D7 retention | Amazon Interview Question