Dechen Consulting interview question

Sql query