'Setting alias name from a subquery in SQL

In my Select query I just want to to set the alias name of a column based on a sub-query (that is, a value in another table). Is this possible in SQL Server 2008?

Like:

SELECT tax_Amt AS (SELECT tax FROM Purchase.tblTax WHERE tax_ID=@tax_ID) 
FROM Table

Any way to achieve the above query?



Solution 1:[1]

Try like this:

SELECT (SELECT tax FROM Purchase.tblTax WHERE tax_ID=@tax_ID) AS tax_Amt  
FROM Table

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 akoso