Re: Doubt about query - Mailing list pgsql-novice

From Gavin Flower
Subject Re: Doubt about query
Date
Msg-id 5574D00A.100@archidevsys.co.nz
Whole thread Raw
In response to Re: Doubt about query  (Bianca Stephani <bianca.stephani@gmail.com>)
List pgsql-novice
Top posting is reply here! And not at the the end of the post.

You are encouraged to intersperse comments in the original post, if the
context is important

On 08/06/15 10:51, Bianca Stephani wrote:
> I'm sorry. What is "top-post"? :/
Explained above!  (An interspersed comment, in this case a bit silly!)

>
> What I want exactly is to get all the values from rows from all 5
> coluns into only one row and one column.
>
> A normal select of columns A, B, C, D would get 5 rows each one with 5
> columns with 1 integer each rowXcolumn, for example. I want as result
> (*as integer, not string*) a single column and single row with a list
> of integers. Is that possible?
>
> What you suggested to me as sql, give me a string of integers
> "1,2,3,4,5,6" and not an array
>
> On Fri, Jun 5, 2015 at 3:38 PM, David G. Johnston
> <david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>> wrote:
>
>     On Fri, Jun 5, 2015 at 2:00 PM, Bianca Stephani
>     <bianca.stephani@gmail.com <mailto:bianca.stephani@gmail.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.
>     ​
>
>
[...]

This is were you should normally reply.

To omit large parts of a previous post you can use '[...]'.
This is a convention I introduced into usenet in the early 1990's!!!
Previously people used '[ omitted ]'


Cheers,
Gavin


pgsql-novice by date:

Previous
From: Gavin Flower
Date:
Subject: Re: Doubt about query
Next
From: Christoffer Westring
Date:
Subject: Re: Doubt about query