Tech Mahindra interview question

A very SQL Query was asked.