Re: How to use result column names in having cause

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: "chris smith" <dmagick(at)gmail(dot)com>, Andrus <eetasoft(at)online(dot)ee>
Subject: Re: How to use result column names in having cause
Date: 2006-03-31 14:46:14
Message-ID: 200603310946.14941.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 31 March 2006 08:30, chris smith wrote:
> On 3/31/06, Andrus <eetasoft(at)online(dot)ee> wrote:
> > >> In real application I have long expression instead of 123 and do'nt
> > >> want repeat this expression in HAVING clause.
> > >
> > > You have to repeat the expression. "AS" changes the output name, it
> > > can't be used either in the where clause or any other limiting factor
> > > like 'having':
> >
> > Doc about HAVING condition says:
> >
> > Each column referenced in condition must unambiguously reference a
> > grouping colum
> >
> > HAVING x> AVG(bar) unambiguously references to a grouping column x
> >
> > Is this bug ? It is very tedious to repeat same column expression in a
> > multiple times: one time in column expression, and n times in having
> > clause.
>
> But you're not referencing x, you're trying to use AVG(bar) in your
> expression.
>
>
> I assume it's this way because the standard says so.. one of the more
> knowledgable list members will be able to confirm/deny this.
>

Yes, this behavior is driven by the sql standards. There is actually a very
nice paper on this subject if you are interested
http://web.onetel.com/~hughdarwen/TheThirdManifesto/Importance-of-Column-Names.pdf

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-03-31 15:03:57 Re: configure: error: file 'tclConfig.sh' is required for Tcl
Previous Message Tony Caduto 2006-03-31 14:43:28 Re: pgsql continuing network issues