I would like to write a statement that looks like this
select 1 as one, 2 as two , one + two as three
However SQL Server cannot work out what one + two
is.
I can re-write in this form
SELECT x.one
,x.two
,x.one + x.two AS three
FROM (
SELECT 1 AS one
,2 AS two
) x
Which gives me the output I expect. It is just a bit messy (and more so in a non-contrived example) I am also not sure what this sort of thing does to the internals of SQL Server and what implications there are to speed of execution.
Is there a better way of doing this?