ROW_NUMBER() with a Deterministic Tie-Breaker
Make deduplication deterministic when the main timestamp can tie.
Evidence tier describes my hands-on relationship with the content. Official sources describe platform contracts/documentation. Production observations should not automatically be treated as official limits.
Two or more rows can share the same primary sort value.
A migration or reconciliation must produce repeatable winners.
SELECT
SubscriberKey,
EmailAddress,
ModifiedDate,
RecordID
FROM (
SELECT
SubscriberKey,
EmailAddress,
ModifiedDate,
RecordID,
ROW_NUMBER() OVER (
PARTITION BY SubscriberKey
ORDER BY ModifiedDate DESC, RecordID DESC
) AS rn
FROM [Source_DE]
) ranked
WHERE rn = 1ROW_NUMBER needs a total ordering inside each partition. A second stable sort key removes ambiguity when the primary timestamp ties.
The tie-breaker must be meaningful and stable; replace RecordID with a real deterministic field from your model.
If both ORDER BY fields can tie, the result can still be nondeterministic.
Do not use NEWID() as a tie-breaker when you need repeatable winners.