From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matthew <matt@ctlno.com>
Cc: 'pgsql-general@hub.org' <pgsql-general@hub.org>
Cc: 'pgsql-interfaces@hub.org' <pgsql-interfaces@hub.org>
Subject: Re: [INTERFACES] Problem using Having in a sub-query wit the Count function.
Date: Wed, 24 Mar 1999 09:54:49 -0500
Message-ID: <26235.922287289@sss.pgh.pa.us> (raw)
In-Reply-To: <A043233669F9D111B99700A0C92376CA0DD6F1@srv.ctlno.com>
Matthew <matt@ctlno.com> writes:
>> "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)"
I wonder whether the parser could be getting confused by the multiple
distinct uses of the same name "ordnum" in this query? In other words,
maybe you'd have better luck if the inner queries read something like
select
k.ordnum from keywordview k where k.keyword='Parade' or k.keyword='Public
Gathering' group by k.ordnum having count(k.ordnum) =2
Without that, it might be thinking that count(ordnum) refers to the
ordnum in the outer select.
If that is it, it's probably a bug, but I'm not sure what the standard
says about how to interpret ambiguous names in this context...
regards, tom lane
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-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, matt@ctlno.com, pgsql-general@hub.org, pgsql-interfaces@hub.org
Subject: Re: [INTERFACES] Problem using Having in a sub-query wit the Count function.
In-Reply-To: <26235.922287289@sss.pgh.pa.us>
* 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