diff --git a/posthog/batch_exports/sql.py b/posthog/batch_exports/sql.py index ba03f9f4bfd07..8236ecb878f74 100644 --- a/posthog/batch_exports/sql.py +++ b/posthog/batch_exports/sql.py @@ -5,12 +5,14 @@ pd.distinct_id AS distinct_id, toString(p.id) AS person_id, p.properties AS properties, + pd.version AS version, pd._timestamp AS _inserted_at FROM ( SELECT team_id, distinct_id, - argMax(person_id, version) AS person_id, + max(version) AS version, + argMax(person_id, person_distinct_id2.version) AS person_id, max(_timestamp) AS _timestamp FROM person_distinct_id2