ZS Associates interview question

SQL queries and puzzles were asked