# v4928_1_5_73 — repair script PostgreSQL ORDER BY fix

Fixes `scripts/repair_opportunity_consistency.py` for PostgreSQL when selecting opportunities by document number.

## Fix

Replaces `SELECT DISTINCT ... ORDER BY o.updated_at` with a grouped query using `ORDER BY MAX(o.updated_at)` so PostgreSQL accepts the statement.

## Usage

```bash
PYTHONPATH=. python scripts/repair_opportunity_consistency.py --document-number ORC.ORC2026.189
```
