X interview question

SQL query