Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL processing values of user defined columns

Tags:

sql

I can do that:

SELECT
   1 AS one,
   2 AS two,
   1 + 2 AS three;

But I would like to do that:

SELECT
    1 AS one,
    2 AS two,
one + two AS three;

Is it possible?

like image 917
taff Avatar asked Sep 27 '26 01:09

taff


1 Answers

You can do this:

SELECT one, two, (one+two) as three
FROM 
(
    SELECT 
         1 AS one 
         2 AS two
) t;
like image 76
p.campbell Avatar answered Sep 29 '26 17:09

p.campbell