Wise interview question

Solve this sql query problem