UBS interview question

Nested SQL Query