ZS Associates interview question

About internship,SQL, puzzles ,how I solved case study