See below for creating aggregates:
http://www.postgresql.org/docs/current/static/xaggr.html
But, there is a useful function built-in, bit_and, that does what you
want:
http://www.postgresql.org/docs/current/static/functions-
aggregate.html#FUNCTIONS-AGGREGATE-TABLE
create table testint (
I have a query which returns a single column of integers which I want
to combine together with &, "bitwise AND". Basically it's a simple
list of access levels that a user might have and I want to merge the
list into one value. There can be zero, one or more values in the list
so I have to be able t