help with aggregation query across a second text array column - Mailing list pgsql-general

From Scot Kreienkamp
Subject help with aggregation query across a second text array column
Date
Msg-id 17082AAFC33A934082836458CB53494374D97CE2@MONDB03.na.lzb.hq
Whole thread Raw
Responses Re: help with aggregation query across a second text array column
List pgsql-general

 

Hi everyone,

 

 

I had a dataset like so:

 

Servername|Primary class

----------------------------------

Server1| retail

Server2| dmz

Server3 | NA

 

 

And I used this query to summarize it for automated tools:

select environment|| ':' || string_agg(name,',') from servers group by environment order by environment;

 

 

Now my dataset has changed to:

Servername text|Primary class text|Secondary class text[1d array]

--------------------------------------------------------------------------------

Server1| retail |[‘dmz’]

 

 

 

There can be multiple classes for secondary but they will be the same classes as the primary classes.  Input is controlled via web pages so that should be guaranteed.  For instance, servers that have primary class of SQL but also belong to an application class.  Now I need to change my summary query to include all the servers for each class taking into account the secondary class column and I’m completely baffled on how to do so with the array.  I know the any trick and use it to match against the array when querying for specific primary and secondary classes but I can’t figure out how to generate the listing the same as the old summary query I was using.  

 

Scot Kreienkamp | Senior Systems Engineer | La-Z-Boy Corporate
One La-Z-Boy Drive | Monroe, Michigan 48162  | ( 734-384-6403 | | ) 7349151444 *  Scot.Kreienkamp@la-z-boy.com
www.la-z-boy.com | facebook.com/lazboy | twitter.com/lazboy | youtube.com/lazboy

 

 

This message is intended only for the individual or entity to which it is addressed.  It may contain privileged, confidential information which is exempt from disclosure under applicable laws.  If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information.  If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.

Attachment

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Recommendation for upgrading from PostgreSQL 9.3
Next
From: Karl Martin Skoldebrand
Date:
Subject: RE: Recommendation for upgrading from PostgreSQL 9.3