Received: from outthere.thinx.ch (outthere.thinx.ch [194.158.233.34]) by hub.org (8.9.3/8.9.3) with ESMTP id PAA84319 for ; Wed, 17 Nov 1999 15:19:54 -0500 (EST) (envelope-from Herbert.Liechti@thinx.ch) Received: from venus.net.thinx.ch (root@dyna-ol-24.dial.eunet.ch [193.72.192.247]) by outthere.thinx.ch (8.9.2/8.9.2) with ESMTP id VAA15201 for ; Wed, 17 Nov 1999 21:19:14 +0100 (CET) Received: from thinx.ch (herbie@tobi.net.thinx.ch [192.168.0.9]) by venus.net.thinx.ch (8.8.8/8.8.8) with ESMTP id VAA01584 for ; Wed, 17 Nov 1999 21:19:12 +0100 Sender: herbie@eunet.ch Message-ID: <383307BC.D8DA8C10@thinx.ch> Date: Wed, 17 Nov 1999 20:53:33 +0100 From: Herbert Liechti Organization: ThinX networked business services X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5 i686) X-Accept-Language: en MIME-Version: 1.0 To: postgres Subject: sql question Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a sql problem which I can't solve. The following table is defined create table AdressGroup ( AdrGroup_Id INTEGER NOT NULL DEFAULT NEXTVAL('adrverw_id_seq'), Zeit DATETIME NOT NULL, Group_Id INTEGER NOT NULL, Adress_Id INTEGER NOT NULL ); The table assigns adresses to adressgroups. I'd like to select the adresses which belongs to one specific adressGroup and to no other group. If an adress has more than one entry in the AdressGroup table it should not be in the projection. I tried the following: SELECT * FROM adressGroup WHERE Group_Id = 6 AND EXISTS( SELECT AdrGroup_Id FROM adressGroup ag_alias WHERE adressGroup.AdrGroup_Id = ag_alias.AdrGroup_Id GROUP BY AdrGroup_Id HAVING COUNT(*) == 1 ); When I do this I get the following error: ERROR: rewrite: aggregate column of view must be at rigth side in qual ERROR: rewrite: aggregate column of view must be at rigth side in qual Does anybody knows the solution? Thanks -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Herbert Liechti E-Mail: Herbert.Liechti@thinx.ch ThinX networked business services Stahlrain 10, CH-5200 Brugg ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~