I want to calculate a summary column on the basis of the column value returning from sub query. I want to use the column name which is returning from the sub query in the calculation of other column.
For example:
select sum(total) as NetTotal, NetTotal/100 * 3.2 Gross from abc group by a
I want to use NetTotal to calculate the other column.
Repeat the aggregate instead of using the alias. If you do want to use the alias, you will need to make the query containing the aggregate into a subquery or cte
select sum(total) as NetTotal, sum(total)/100.0 * 3.2 Gross from abc group by a