Can someone let me know if its possible to execute calculations on a column alias.
I know its possible with SAS, see below:
Referring to a Calculated Column by Alias
When you use a column alias to refer to a calculated value, you must use the CALCULATED keyword with the alias to inform PROC SQL that the value is calculated within the query. The following example uses two calculated values, LowC and HighC, to calculate a third value, Range:
libname sql 'SAS-library';
proc sql outobs=12;
title 'Range of High and Low Temperatures in Celsius';
select City, (AvgHigh - 32) * 5/9 as HighC format=5.1,
(AvgLow - 32) * 5/9 as LowC format=5.1,
(calculated HighC - calculated LowC)
as Range format=4.1
As you can see from above SAS code, it is possible to execute a query on an alias using the CALCULATED keyword.
Is there an equivalent with T-SQL?