Click here to Skip to main content
16,011,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to do addition of column without using aggregate function SUM()
Posted
Comments
CPallini 6-Aug-14 4:31am    
Why don't you want to use it?
vishavajeet 6-Aug-14 4:49am    
in last interview interviwer askd me this question.But still I cant able to do that.

SQL
DECLARE @SUM AS INT --?
SET @SUM = 0
SELECT @SUM = @SUM + COLUMN_TO_AGGREGATE FROM MY_TABLE
And this is the most stupid way to do it - build in aggregate functions are much more faster...
 
Share this answer
 
using a variable in sql
Declare @Va as decimal.
set @Va=0

and query write like

select @Va=@Va+Columnname from Table
 
Share this answer
 
v2
Comments
Kornfeld Eliyahu Peter 6-Aug-14 5:35am    
Can you fix your obvious SQL problems?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900