Pergunta de entrevista da empresa Comeet

Optimize a SQL query. It was about 15 lines of code.