Fidelity Investments Interview Question

Given a scenario, write the correct query.