Capgemini interview question

SQL query