Intango interview question

Solve this problem on SQL in video call