Link to home
Start Free TrialLog in
Avatar of lobos
lobos

asked on

sql sum on nvarchar field

I have a table that is labeled as a nvarchar and it contains only numbers, I want to do a query like below (sum) but I get error because its a nvarchar field.

select sum(startingbid) as totalvaue from items

The sum or average aggregate operation cannot take a nvarchar data type as an argument.

changing the column to an int is not an option...
ASKER CERTIFIED SOLUTION
Avatar of Nightman
Nightman
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note: if there are any non-numeric characters in this field, you will get an error. You really need to move towards storing your data in the correct type.
Avatar of lobos
lobos

ASKER

I understand this, but this has gone live already and there is not much of a choice, plus this is just a pilot project...
turns out...int wont work because there are decimal values....
so change I just int to decimal and it will be good?
Yes, that would work fine.