Re: [GENERAL] DISTINCT in STRING_AGG

2015-11-30 Thread Sterpu Victor
t are the coordinates for each node and the result must be ordered by this to obtain the correct result. -- Original Message -- From: "Geoff Winkless" To: "Sterpu Victor" Cc: "PostgreSQL General" Sent: 11/29/2015 10:51:32 PM Subject: Re: Re[2]: [GENE

Re: [GENERAL] DISTINCT in STRING_AGG

2015-11-29 Thread Geoff Winkless
On 29 November 2015 at 20:51, ​I wrote: > Well you could look at the intarray ​extension and a combination of > array_agg, uniq() and > *​​string_to_array*: ​Mind blip, apologies, obviously I meant array_to_string :)​ ​Geoff​

Re: [GENERAL] DISTINCT in STRING_AGG

2015-11-29 Thread Geoff Winkless
On 29 November 2015 at 18:59, Sterpu Victor wrote: > I can't skip the ordering. > I'm sure aqjs3 is the one that produces the duplication. > I guess subqueries are the only option, like this: ​Well you could look at the intarray ​extension and a combination of array_agg, uniq() and string_to_ar

Re: [GENERAL] DISTINCT in STRING_AGG

2015-11-29 Thread Sterpu Victor
1399031" 1399031;"1399032,1399033" Is there a better way? I usualy try to avoid subqueries. -- Original Message -- From: "Geoff Winkless" To: "Sterpu Victor" Cc: "PostgreSQL General" Sent: 11/29/2015 6:42:18 PM Subject: Re: [GENERAL] DISTINCT

Re: [GENERAL] DISTINCT in STRING_AGG

2015-11-29 Thread Geoff Winkless
On 28 November 2015 at 18:35, Sterpu Victor wrote: > Can I make a distinct STRING_AGG? > This is my query : > SELECT atjs.id, STRING_AGG(CAST(aqjs1.id AS VARCHAR), ',' ORDER BY > aqjs1.to_left) AS children > FROM administration.ad_query_join_select atjs > JOIN administration.ad_query aq ON (aq.id

Re: [GENERAL] DISTINCT in STRING_AGG

2015-11-28 Thread John J. Turner
On Nov 28, 2015, at 1:35 PM, Sterpu Victor wrote: > Hello > > Can I make a distinct STRING_AGG? > This is my query : > SELECT atjs.id, STRING_AGG(CAST(aqjs1.id AS VARCHAR), ',' ORDER BY > aqjs1.to_left) AS children > FROM administration.ad_query_join_select atjs > JOIN administration.ad_query

[GENERAL] DISTINCT in STRING_AGG

2015-11-28 Thread Sterpu Victor
Hello Can I make a distinct STRING_AGG? This is my query : SELECT atjs.id, STRING_AGG(CAST(aqjs1.id AS VARCHAR), ',' ORDER BY aqjs1.to_left) AS children FROM administration.ad_query_join_select atjs JOIN administration.ad_query aq ON (aq.id=atjs.id_ad_query) LEFT JOIN administration.ad_query_jo