Pregunta de entrevista de Russell Investments

what would be the sql script for this?