pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Weilers <david@lionhead.nl>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Double aggregate problem
Date: Wed, 22 Jul 2009 18:16:21 +0200
Message-ID: <H00000670039e901.1248279381.lionhead2.lionhead.nl@MHS> (raw)

Dear anyone,

I have the following query:

select v.id, array_to_string(array_accum(s.name),', ') as sector , 
array_to_string(array_accum(p.name),', ') as provincie from tblvacature 
v, tblaccount a , tblvacaturesector vs, tblsector s , 
tblvacatureprovincie vp, tblprovincie p where v.id = 11 and v.account = 
a.id and vs.vacature = v.id and s.id = vs.sector and vp.vacature = v.id 
and p.id = vp.provincie group by v.id, v.inserted order by v.inserted 
desc

That currently produces the following output:

id |                      sector                       |                 

                   provincie
----+---------------------------------------------------+---------------
-------------------------------------------------------------------
 11 | Gaafjes, Eerder, Gaafjes, Eerder, Gaafjes, Eerder | Noord-Holland, 

Noord-Holland, Limburg, Limburg, Oost-Vlaanderen, Oost-Vlaanderen

If i leave out one aggregate, the result is as i expect (if I leave out 
'provincie', sector gives):

Gaafjes, Eeerder

Only two results.

I would like both array_accum returning only what they should and not 
doubles.

Any help is appreciated.

--
Regards,

David Weilers



view thread (5+ messages)  latest in thread

Message-ID: <H00000670039e901.1248279381.lionhead2.lionhead.nl@MHS>
Permalink:  ../H00000670039e901.1248279381.lionhead2.lionhead.nl@MHS/
Also on:    postgresql.org/message-id/H00000670039e901.1248279381.lionhead2.lionhead.nl@MHS

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: david@lionhead.nl
  Subject: Re: Double aggregate problem
  In-Reply-To: <H00000670039e901.1248279381.lionhead2.lionhead.nl@MHS>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox