Pregunta de entrevista de Starbucks

It was a Leetcode medium SQL question.