From: | Bob Messenger <bob(at)cassiancapital(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Simple SQL |
Date: | 2003-10-24 13:16:41 |
Message-ID: | 3f992639$0$12714$fa0fcedb@lovejoy.zen.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Alvaro Herrera wrote:
> On Fri, Oct 24, 2003 at 07:25:44AM +0200, Pavel Stehule wrote:
>
>>Not
>>
>>SELECT 1 as a, a*2;
>>ERROR: column "a" does not exist
>
>
> But you can try
>
> SELECT a, a*a FROM (select 1 as a);
>
>
>>On Tue, 21 Oct 2003, Bob Messenger wrote:
>>
>>
>>>Is it possible to do something like:
>>>
>>> select 1 as a, a*a;
>>>
>>>in postgres?
>
>
alien=# SELECT a, a*a FROM (select 1 as a);
ERROR: sub-SELECT in FROM must have an alias
For example, FROM (SELECT ...) [AS] foo
Thanks for idea though. It led me to this:
alien=# SELECT a, a*a FROM (SELECT 2 AS a) AS a;
a | ?column?
---+----------
2 | 4
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | Vilson farias | 2003-10-24 13:28:15 | Timestamp and interval precision |
Previous Message | John DeSoi | 2003-10-24 12:43:10 | shared memory on OS X - 7.4beta4 |