Oviva interview question

Question was related SQL query