Infosys interview question

Question form SQL and puzzles