Deloitte interview question

SQL query