Why aggregate functions in PostgreSQL do not work with boolean data type
问题 Why we cannot use boolean values in aggregate functions without casting to some integer type first? In many cases it makes perfect sense to calculate sum, average or correlation from columns of boolean data type. Consider the following example where boolean input has to be always casted to int in order to make it work: select sum(boolinput::int), avg(boolinput::int), max(boolinput::int), min(boolinput::int), stddev(boolinput::int), corr(boolinput::int,boolinputb::int) from (select (random() >