Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Calculation of one column on the basis of column f

Author  Topic 

afreenraja
Starting Member

1 Post

Posted - 2013-01-23 : 16:04:39
Hi All,

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.

Could anyone please help me on this.


Thanks in advance.

Regards,

Afreen

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-23 : 17:44:03
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 
Go to Top of Page
   

- Advertisement -