argument 'and' incorrect, sum values of attributes
You should use a comparison operator like &gt; &lt; = &gt;= &lt;=

create table t (id int);
select case when (select count(*) from t) then 1 else 0 end



  ERROR:  argument of CASE/WHEN must be type boolean, not type bigint
  LINE 1: select case when (select count(*) from t) then 1 else 0 end


select case when (select count(*) from t) &gt; 0 then 1 else 0 end
                                          ^^^




| case |
| ---: |
|    0 |



db&lt;>fiddle here