Reputation: 157
If I have a column which store boolean values, how can I apply OR operator over several rows of that column? I hope I don't have to use joins.
Upvotes: 1
Views: 629
Reputation: 6427
You can use postgres aggregate functions for this, specifically bool_or
and bool_and
aggregate functions
create table bools (
a boolean
);
insert into bools values(true), (true), (false);
select bool_or(a) from bools;
here is a working example https://www.db-fiddle.com/f/fBoZzyXzF4H28tALVupZfC/1
Upvotes: 4