Re: WHERE on an alias

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Joseph Shraibman <jks(at)selectacast(dot)net>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: WHERE on an alias
Date: 2001-08-24 19:27:30
Message-ID: Pine.BSF.4.21.0108241225480.23698-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Fri, 24 Aug 2001, Joseph Shraibman wrote:

> playpen=# select a, sum(b) as dsum from taba where dsum > 5 group by(a);
> ERROR: Attribute 'dsum' not found
>
> Why can we GROUP BY on an alias but not do a WHERE on an alias? I have a subselect that
> explain shows is being run twice if I have to put it in the WHERE clause.

Somewhat unrelated question, are you sure you want where and not having?
IIRC, where is going to select rows before things like the group by
occur, and that doesn't seem to be what you'd want here, right?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joseph Shraibman 2001-08-24 19:31:14 Re: WHERE on an alias
Previous Message Joseph Shraibman 2001-08-24 18:11:51 WHERE on an alias