Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.2/8.9.1) with ESMTP id JAA37644; Wed, 24 Mar 1999 09:54:37 -0500 (EST) (envelope-from sferac@bo.nettuno.it) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.6/NETTuno 3.1) with ESMTP id PAA10810; Wed, 24 Mar 1999 15:54:27 +0100 (MET) Received: from rosso.sferacarta.com (bo.nettuno.it) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 10PoaH-0008PY-00; Wed, 24 Mar 1999 14:24:41 +0000 Message-ID: <36F8E7B2.39310407@bo.nettuno.it> Date: Wed, 24 Mar 1999 14:25:06 +0100 From: Ordini X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: Matthew CC: "'pgsql-general@hub.org'" , "'pgsql-interfaces@hub.org'" Subject: Re: [INTERFACES] Problem using Having in a sub-query wit the Count function. References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit bug: HAVING IN SUBQUERIES ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is a known bug. Jose' > > We are trying to execute a query that has several sub-queries embedded > > in it. Below is a snippet of the sql code. > > > > "Select ordnum from ordinace where dept='Finance' and ordnum in > > (Select ordnum from squareview where square='A') and ordnum in (select > > ordnum from keywordview where keyword='Parade' or keyword='Public > > Gathering' group by ordnum having count(ordnum) =2)" > > > > The two tables in the sub-queries (squareview and keywordview) or > > views created between two tables. > > There are roughly about 20000 records in the keywordview view. > > > > When we execute the query, failing at the keywordview subquery, saying > > the aggregate function in the having clause must appear on the right > > side. (?) When we take the having clause out, and strictly have the > > group by, it takes 30secs to 3mins. to return with the valid > > recordset. > > > > The funny thing is, as a stand alone query on it's own, the > > keywordview query works fine. It's very quick and has no problem with > > the having clause. > > > > I was wondering if anyone else has either had this problme using > > aggregate functions with the having clause in a subquery, or could > > anyone give me any information of successfully executing something > > similar to this. > > > > Any infomation would be appreciated. > > > > Thanks in advance, > > > > Steve > > steve@ctlno.com