Mercer interview question

how to optimize query, sql