Re: Converting from MS Access field aliases

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Joel Richard <postgres(at)joelrichard(dot)com>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Converting from MS Access field aliases
Date: 2007-07-12 16:36:50
Message-ID: 746273.93291.qm@web54305.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


> SELECT field1 / 2 AS foo,
> field2 * 2 AS bar,
> foo + bar AS total
> WHERE foo < 12;
>
> The first two fields are fine, it's the third that's a problem. The
> database reports
>
> ERROR: column "foo" does not exist
>

First, I think it would be great if this worked - like the alias to an
update table added in 8.2 - saves a lot of typing and makes queries
much more readable.

Second, only way I see is to set this on top of a view generating your
foo and bar aliases, and go from there. Compared to rewriting the
expression each time, it has the advantages of better syntax in the end
and might yield better performance as well.


____________________________________________________________________________________
Got a little couch potato?
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-07-12 17:23:00 Re: Converting from MS Access field aliases
Previous Message Nicholas Barr 2007-07-12 15:55:16 Re: Converting from MS Access field aliases