Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple SQL question

Re: Simple SQL question

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sat, 7 Dec 2002 11:18:36 +0100
Message-ID: <uv3iu89e2f5je6@corp.supernews.com>

"Paul Taylor" <paul.taylor_at_zen.co.uk> wrote in message news:4ig3vu42pp3m54q42ha6k2bokkck2541pr_at_4ax.com...
> I can't seem to find the answer to this question anywhere.
>
> If I have a query such as:
>
> SELECT x/2, y+3 FROM mytable;
>
> Is it possible to use the calculated values x/2 and y+3 in another
> column? I was thinking of something like:
>
> SELECT x/2 AS a, y+3 AS b, a + b FROM mytable;
>
> I'm thinking more of cases where the expressions would be a lot more
> complex (like nested SELECTS). I have a situation where I have 2
> nested selects and I want to perform a calculation on the results and
> use that as a third column. Is there some way to do what I want? In
> the example above I get an error stating that columns a and b don't
> exist.
>
> Thanks.

select a, b, a+b
from
(select x+2 a

         , y+3 b
 from mytable
)

--
Sybrand Bakker
Senior Oracle DBA

to reply remove '-verwijderdit' from my e-mail address
Received on Sat Dec 07 2002 - 04:18:36 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US