Re: [SQL] [noob] How to optimize this double pivot query?

2012-10-03 Thread Robert Buck
Thank you, Samuel. I am trying some of this out right now... This is great information. Thanks so much. This is a huge help. Bob On Tue, Oct 2, 2012 at 4:09 PM, Samuel Gendler wrote: > One last comment - an alternative solution to this is to use array_agg(), > which will simply add each value

Re: [SQL] [noob] How to optimize this double pivot query?

2012-10-03 Thread Robert Buck
Samuel, You asked: Some questions before I provide crosstab samples - your example query has a hardcoded set of keys that it is looking for, but maybe that was code-generated. There are multiple forms of the crosstab function, some of which rely on a constant column count and others which can ge

Re: [SQL] [noob] How to optimize this double pivot query?

2012-10-03 Thread Samuel Gendler
On Wed, Oct 3, 2012 at 9:31 AM, Robert Buck wrote: > Samuel, > > You asked: > > Some questions before I provide crosstab samples - your example query has > a hardcoded set of keys that it is looking for, but maybe that was > code-generated. There are multiple forms of the crosstab function, some