I have a qty column in my table, and i’m trying to sum the values. The field type is varchar(20). The sum of qty below should add up to exactly 0. It’s a mix of negative and positive decimals.
exhibit A (screenshot)
When i perform the sum below, i’m getting a tonne of decimals instead of 0. I’m assuming this is a datatype issue. What’s the best way to work around this?
exhibit B (screenshot)
You should not be storing numeric data as a string but if you do, then you will need to
cast()it to apply aSUM()aggregate to it:So your query will be: