Note the use of aliases, w and x. You are using a correlated subquery.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных