# Pick a surviving record

Join / survivorship

collapse each group of matched records into one surviving record by per-field rules

Page: <https://meridian.online/operations/pick-a-surviving-record>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

one surviving record per group, by a rule per field

```sql
CREATE TEMP TABLE result AS
WITH recs(group_id, name, email, updated) AS (VALUES
       (1, 'Bob Okafor',  NULL,          DATE '2026-01-01'),
       (1, 'Bob  Okafor', 'bob@example.org',     DATE '2025-06-01'),
       (1, 'B. Okafor',   'bob.old@example.org', DATE '2024-01-01'),
       (4, 'Carla Díaz',  NULL,          DATE '2026-02-01'))
SELECT group_id,
       arg_max(name, updated) AS name_latest,
       arg_max(email, updated) FILTER (WHERE email IS NOT NULL) AS email_latest_known,
       max(updated) AS updated, count(*) AS merged
FROM recs GROUP BY group_id ORDER BY group_id;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT max(name_latest) FILTER (WHERE group_id = 1) = 'Bob Okafor' AND max(email_latest_known) FILTER (WHERE group_id = 1) = 'bob@example.org' AND max(merged) FILTER (WHERE group_id = 1) = 3 AND count(*) FILTER (WHERE group_id = 4 AND email_latest_known IS NULL) = 1 FROM result)) THEN 'as expected' ELSE error('the survivor did not take the latest name and the latest known email') END AS verdict;
```

The statement builds its own data.

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Duckle: [`Survivorship (Golden Record)`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/frontend/src/workflow-ui/palette-data.ts) (read 2026-09-25)
- Talend: [`tRuleSurvivorship`](https://help.qlik.com/talend/en-US/components/8.0/deduplication/deduplication-component) (read 2026-09-27)
