ZS Associates interview question

Few puzzles and some questions around SQL