select coalesce(t1.col1, t2.col2) as "группировка"
, coalesce(t1.c, 0) as "кол-во_1"
, coalesce(t2.c, 0) as "кол-во_2"
from (select col1, count(*) c from test group by col1) t1
full join
(select col2, count(*) c from test group by col2) t2 on t1.col1 = t2.col2
order by 1
;
select *
from users
where not exists (
select 1
from tasks
where executor_id = users.id
and status in ('wip','new'))