Dehaat interview question

Problem understanding and solving. - Puzzle - SQL - Quick thinking