Problem with aliasing - Mailing list pgsql-general

From Jean-Christian Imbeault
Subject Problem with aliasing
Date
Msg-id 3E560203.9020207@mega-bucks.co.jp
Whole thread Raw
Responses Re: Problem with aliasing  (Greg Stark <gsstark@mit.edu>)
List pgsql-general
I wrote a plpgsql function to return the maximum of three dates.

TAL=# select max(req_del_date1, req_del_date2, req_del_date3) as ma1
from invoices;
     ma1
------------
  2003-02-25
  2003-02-25
(2 rows)


However I'm having problems with the following query:

TAL=# select max(req_del_date1, req_del_date2, req_del_date3) as max
from invoices where max <= now();
ERROR:  Attribute "max" not found

Why can't the where part of the query see "max"? I've tried aliasing the
returned value but that did not work either:

TAL=# select max(req_del_date1, req_del_date2, req_del_date3) as ma1
from invoices where ma1 <= now();
ERROR:  Attribute "ma1" not found

What is wrong with my syntax?

Thanks!

Jc


pgsql-general by date:

Previous
From: "Guido Notari"
Date:
Subject: Re: Backend often crashing
Next
From: Richard Huxton
Date:
Subject: Re: max connections