Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] Problem using Having in a sub-query wit the Count function.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthew <matt(at)ctlno(dot)com>
Cc: "'pgsql-general(at)hub(dot)org'" <pgsql-general(at)hub(dot)org>, "'pgsql-interfaces(at)hub(dot)org'" <pgsql-interfaces(at)hub(dot)org>
Subject: Re: [INTERFACES] Problem using Having in a sub-query wit the Count function.
Date: 1999-03-24 14:54:49
Message-ID: 26235.922287289@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-interfaces
Matthew <matt(at)ctlno(dot)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

pgsql-interfaces by date

Next:From: Byron NikolaidisDate: 1999-03-24 15:20:44
Subject: [Fwd: [INTERFACES] type error inserting large obj, Win32 ODBC]
Previous:From: Byron NikolaidisDate: 1999-03-24 14:35:41
Subject: Re: [INTERFACES] Invalid BLOB Length

pgsql-general by date

Next:From: MarkDate: 1999-03-24 21:50:55
Subject: MkLinux & ODBC compile error
Previous:From: OrdiniDate: 1999-03-24 13:25:06
Subject: Re: [INTERFACES] Problem using Having in a sub-query wit the Count function.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group