pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Claverie <Steve@ctlno.com>
To: 'pgsql-general@hub.org' <pgsql-general@hub.org>
To: 'pgsql-interfaces@hub.org' <pgsql-interfaces@hub.org>
Subject: Problem using Having in a sub-query wit the Count function.
Date: Tue, 23 Mar 1999 12:44:24 -0600
Message-ID: <A043233669F9D111B99700A0C92376CA0F34B1@srv.ctlno.com> (raw)

Hey,

	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



view thread (4+ messages)  latest in thread

Message-ID: <A043233669F9D111B99700A0C92376CA0F34B1@srv.ctlno.com>
Permalink:  ../A043233669F9D111B99700A0C92376CA0F34B1@srv.ctlno.com/
Also on:    postgresql.org/message-id/A043233669F9D111B99700A0C92376CA0F34B1@srv.ctlno.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-interfaces@postgresql.org
  Cc: Steve@ctlno.com, pgsql-general@hub.org, pgsql-interfaces@hub.org
  Subject: Re: Problem using Having in a sub-query wit the Count function.
  In-Reply-To: <A043233669F9D111B99700A0C92376CA0F34B1@srv.ctlno.com>
  References: <A043233669F9D111B99700A0C92376CA0F34B1@srv.ctlno.com>

* 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