sql server - Using Sum(Cast(Replace syntax -
i trying write simple query in order change of our stage data. have varchar $ column (unfortunately) needs summed. issue because of commas, cannot change datatype. so, can use replace(amt,',','')
remove commas still wont let me cast decimal ,
error converting data type varchar numeric.
i trying following below no luck. ideas? can done or using wrong syntax here?
select sum(cast(replace(amt,',','') decimal (18,2)) )
i able resolve @habo suggestion. used cast(ltrim(rtrim(table.amt)) money)
instances of varchar
amount. removed white space , removed commas numbers.
Comments
Post a Comment