Pergunta de entrevista da empresa Fidelity Investments

Given a scenario, write the correct query.