Re: dynamic crosstab

From: Balázs Klein <Balazs(dot)Klein(at)t-online(dot)hu>
To: "'Erik Jones'" <erik(at)myemma(dot)com>
Cc: "'Tino Wildenhain'" <tino(at)wildenhain(dot)de>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: dynamic crosstab
Date: 2008-02-15 16:40:12
Message-ID: 20080215164012.390B0ACB77@mail00a.mail.t-online.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> > Do youthink there is a way to ensure that the order of the values in the
> > array below is the same for each person?
> >
> > tbl(eID, aID, value)
> >
> > Select eID, array_accum(value) from
> > (
> > (Select Distinct eID from tbl) e
> > CROSS JOIN
> > (Select Distinct aID from tbl) a
> > ) ea
> > LEFT OUTER JOIN
> > tbl USING (eID, aID)
> > GROUP BY eID
>
> The only way to ever guarantee a particular order is via an ORDER BY
> clause.

Sure. I just didn’t know where to put it - most aggregates don't care about the row order, but for this one it is important.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-02-15 16:45:32 Re: Pains in upgrading to 8.3
Previous Message paul rivers 2008-02-15 16:39:57 Re: Pains in upgrading to 8.3