Note to self: works if I directly reference outer query column name from the inner query.
Still no Idea why it does not work with the alias.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных