Finance wants session counts by the default model each agent was running when the session took place. The default model is set on the agent version, and agents have been moved between models during the year. The interviewer adds a condition: find the version from the release dates, then show that it agrees with the version key stored on the session.
Return model_name (the model of the version in force when the session started), sessions, and matches_stored_version (sessions where the version in force is the one stored on the session row). To find a session's agent, follow sessions.agent_version_id to agent_versions.agent_id. Then find the version in force without that key: it is the agent_versions row for the same agent with deployed_at on or before the session's started_at and retired_at either empty or after it. Order by sessions from highest to lowest, then by model_name.
Create a free account to save your progress and reveal the worked answer for this free exercise. The complete practice library is available with Practice Pass or Mastery.