SELECT foo.*, npoints( foo.g ) FROM (SELECT a, (select b from c where d = e limit 1) AS g FROM f WHERE isValid( g )) AS foo ?
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных