names in WHERE and HAVING - Mailing list pgsql-general

From Zachary Beane
Subject names in WHERE and HAVING
Date
Msg-id 20001204114911.Y14297@xach.com
Whole thread Raw
Responses Re: names in WHERE and HAVING  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I was reading the docs about SELECT and I came across this:

name

      Specifies another name for a column or an expression using the
      AS clause.  This name is primarily used to label the column for
      display. It can also be used to refer to the column's value in
      ORDER BY and GROUP BY clauses. But the name cannot be used in
      the WHERE or HAVING clauses; write out the expression instead.

What is the reason for this restriction? It would be a great
convenience if it were lifted.

I have several queries against another database system that do
something like this:

   select name, count(*) as score
   from mytable
   group by name
   having score > 10

PostgreSQL doesn't like them...

Zach
--
xach@xach.com     Zachary Beane     http://www.xach.com/

pgsql-general by date:

Previous
From: Phil Steinke
Date:
Subject: plpgsql variable trouble
Next
From: Chris Jones
Date:
Subject: "temporary" table is still there