Hi, I would like to ask you how in PostgreSQL can you check if one of boolean values in table's column is true using select or aggregate function?
Thanks.
Hi, I would like to ask you how in PostgreSQL can you check if one of boolean values in table's column is true using select or aggregate function?
Thanks.
You can't use SUM(DATA) but you could cast the value (see below) to int (0=false, 1=true). However it may be more efficient to use EXISTS(...), specially if you are not interested in the number of TRUE values.
create table test(data boolean);
insert into test values(true), (false);
select sum(cast(data as int)) from test;
select exists(select * from test where data);