Write SQL using joins and window functions | Capital One Interview Question