Pregunta de entrevista de State Street

How would you go about solving this problem in SQL?