July 4, 2003 at 3:20 am
Hi
Does anyone know how to assign the value of a compute sum(field) to a variable??
Thanks
Ritch
*I didn't do anything it just got complicated*
"I didn't do anything it just got complicated" - M Edwards
July 4, 2003 at 4:51 am
Hi Ritch,
I think this is what you need :
Declare @Store Int
SELECT @Store = Sum(Field) from Table
One thing to consider - assuming that Field is of data type int and the sum of all Field values exceeds the maximum value for Int data type then you might have to rewrite it as :
Declare @Store Numeric(28,3)
SELECT @Store = Sum (Convert(Numeric(28,3),Field)) from Table
i.e cast the Sum and the variable to a datatype that can hold the result...
July 4, 2003 at 5:00 am
Thanks Winash
*I didn't do anything it just got complicated*
"I didn't do anything it just got complicated" - M Edwards
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply