Skip to interview prep
Apexed

27. How would you select one latest status per application when several updates can share the same timestamp?

MediumSQL

Technical
Show model answer

Define a deterministic tie-breaker from the source contract, such as a monotonically increasing event sequence. Rank updates within each application by timestamp and that sequence, then select the first row.

Do not pick MAX(status) alongside MAX(timestamp), since they may come from different rows. Decide how corrections, duplicate events and late arrivals work, and test tied timestamps explicitly. If the source has no valid ordering, surface that ambiguity.

What interviewers listen for

  • Deterministic ordering
  • Select a complete source row
  • Handle late and tied events
How would you select one latest status per application when several updates can share the same timestamp — Data & analytics interview question — Apexed