Pergunta de entrevista da empresa Amazon

How would you optimise this sql query?