Citi interview question

SQL query