Pregunta de entrevista de Matrix IT

Sql question. Middle difficulty one