Problem with aliasing

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Problem with aliasing
Date: 2003-02-21 10:40:03
Message-ID: 3E560203.9020207@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-02-21 10:50:17 Re: max connections
Previous Message Guido Notari 2003-02-21 08:50:11 Re: Backend often crashing