BNY interview question

Hacker Rank test using SQL