Re: Doubt about query

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bianca Stephani <bianca(dot)stephani(at)gmail(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Doubt about query
Date: 2015-06-05 18:38:29
Message-ID: CAKFQuwakYSDBzKQPyodvNYJNRUuAO-2bO56soOy66=JeG4J+Gg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Jun 5, 2015 at 2:00 PM, Bianca Stephani <bianca(dot)stephani(at)gmail(dot)com>
wrote:

> Thanks for answering. I've already tryied that. When I do what you've
> said, i get this:
>
> [{"array" => "{1,2,3,4,5}"}, {"array" => "6,7,8,9,10}"}...]
>
> When what i want is this: [1,2,3,4,5,6,7,8,9,19]
>
>
​Please don't top-post...

Nowhere are you mentioning JSON but I presume what you are trying to do
involves that...

I'm not sure how you expect to the 10 numbers when you only want to
concatenate 5 columns...

You should share what you have done and the sample data you are using.

SELECT array_agg(unnest) AS row_agg FROM (
SELECT unnest(col_agg) FROM (
SELECT ARRAY[...] AS col_agg FROM ...
)));

​That gets you a single array with all the rows and columns in the same
dimension.​

David J.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bianca Stephani 2015-06-07 22:51:37 Re: Doubt about query
Previous Message Bianca Stephani 2015-06-05 18:00:20 Re: Doubt about query