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

2012-10-02 Thread Samuel Gendler
One last comment - an alternative solution to this is to use array_agg(), which will simply add each value that matches a group by clause to an array. If you are careful to structure your query with left joins so that every grouping will have the same number of rows, then you can get a quick and d

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

2012-10-02 Thread Samuel Gendler
On Tue, Oct 2, 2012 at 2:45 AM, Robert Buck wrote: > Hi Samuel > > Thank you. This may be a bit of a stretch for you, but would it be > possible for me to peek at a sanitized version of your cross tab query, for > a good example on how to do this for this noob? > > This will be pretty common in m

Re: [SQL] Help in accessing array

2012-10-02 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of mephysto > Sent: Thursday, September 27, 2012 6:12 AM > To: pgsql-sql@postgresql.org > Subject: [SQL] Help in accessing array > > Hi to everyone, > I have a little problem to

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

2012-10-02 Thread Robert Buck
Hi Samuel Thank you. This may be a bit of a stretch for you, but would it be possible for me to peek at a sanitized version of your cross tab query, for a good example on how to do this for this noob? This will be pretty common in my case. The biggest tables will get much larger as they are r

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

2012-10-02 Thread Samuel Gendler
On Mon, Oct 1, 2012 at 11:46 PM, Thomas Kellerer wrote: > > That combined with the tablefunc module (which let's you do pivot queries) > might > make your queries substantially more readable (and maybe faster as well). > > I woud think that using the crosstab functions in tablefunc would solve th

[SQL] Help in accessing array

2012-10-02 Thread mephysto
Hi to everyone, I have a little problem to retrieve data from multidimensional array. For example, if I have this array foo[][] = {{5,3},{2,2}} how can I retrieve one of two internal array (for example I would to retrieve {5,3}? I tried foo[1:1] but the result is {{5,3}}, not {5,3}. Is a method