WITH account_status AS (select CASE WHEN regdate = 1 THEN 'yes' WHEN regdate = 2 THEN 'no' from test1 end as status_a)select status_a from account_status group by status_a
WITH user_status AS (select CASE WHEN regdate = 1 THEN 'yes' WHEN regdate = 2 THEN 'no' from test1 join test2 as t2 on t2.test1_id = t1.id end as status_a)select status_a from user_status group by status_a
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных