Pergunta de entrevista da empresa HackerRank

Writing a SQL query for some problem that I don't remember