So, what about using FILTER here? We already use it for aggregates when filtering rows to process.
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных