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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Calculation of one column on the basis of column f
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 01/23/2013 :  16:04:39  Show Profile  Reply with Quote
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.



Edited by - afreenraja on 01/23/2013 16:13:15

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 01/23/2013 :  17:44:03  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000