Re: Doubt about query - Mailing list pgsql-novice

From Bianca Stephani
Subject Re: Doubt about query
Date
Msg-id CAL5He_dsQL8+hzJzzzvotOWMVymNqhU6rrVo2inYUDN2hhDeJQ@mail.gmail.com
Whole thread Raw
In response to Re: Doubt about query  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Doubt about query  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-novice
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] 

:/


On Fri, Jun 5, 2015 at 2:40 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Fri, Jun 5, 2015 at 1:25 PM, Bianca Stephani <bianca.stephani@gmail.com> wrote:
HI everyone. 

I have a table with X columns. And I want to make a select of 5 of the X columns in a way that i get all the 5 columns values only in one column (like i call everyone "AS bla" and as result, bla is an array of that columns), but if i use 5 selects with UNION ALL i just get [{bla => 3}, {bla => 3}, {bla => 1}, {bla => 5}, {bla => 2} ...] even with a GROUP BY. And besides that, using "as bla" is turning my results (3, 1, 5, 2) into strings.

What is the best way to collect the value of multiple integer columns as one? :|


​Do you have a particular output column type you'd like the data to be in?​

​SELECT ARRAY[col1, col2, col3, col4, col5]::integer[] FROM tbl

David J.



--
Bianca Stephani.

"Killing time before time kill us"
"Panic called you out and took you in, giving you an easy game and letting you win"
"Who's gonna love you when you reach the end?"
"A diferença entre a vida e a arte é que a arte é mais suportável"
"Smile like you mean it"
"I told you I was brave, but I've lied"
"If you don't do anything, nothing can happen"

pgsql-novice by date:

Previous
From: "lmanorders"
Date:
Subject: Windows Install Error getlocales.exe
Next
From: "David G. Johnston"
Date:
Subject: Re: Doubt about query