pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Quinney <stephen.quinney@computing-services.oxford.ac.uk>
To: pgsql-sql@postgresql.org
Subject: Combining values in a column
Date: Fri, 15 Apr 2005 10:22:27 +0100
Message-ID: <20050415092227.GA24135@computing-services.oxford.ac.uk> (raw)

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 to cope with the no-results .

For example

 access
--------
     31
    511

Would lead to 31 & 511 which gives 31.

I guess really this can lead to the more generic question. How do I
apply a general function to combine the values, if I, for example,
wanted to write my own aggregate function like sum?

Thanks in advance,

Stephen Quinney







view thread (2+ messages)  latest in thread

Message-ID: <20050415092227.GA24135@computing-services.oxford.ac.uk>
Permalink:  ../20050415092227.GA24135@computing-services.oxford.ac.uk/
Also on:    postgresql.org/message-id/20050415092227.GA24135@computing-services.oxford.ac.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: stephen.quinney@computing-services.oxford.ac.uk
  Subject: Re: Combining values in a column
  In-Reply-To: <20050415092227.GA24135@computing-services.oxford.ac.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox