SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

afreenraja
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.

Regards,

Afreen

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

James K
Flowing Fount of Yak Knowledge

3573 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000