whitsey wrote:
I have a column in a database which saves results from a remote
machine which is related to qty on hand.
The problem is that qty's are numeric if 0, however some 0 results
are saved as "No" and if the part has never been stocked, it is
returned as "Not Carried"
If I simply do a sum(qty) it throws an error.
What to do???
I assume your column is some kind of char type, so first you will have
to cast it to a type which sum can use. Second you need to filter out
rows that cant be casted. Perhaps you can use something like:
[lelle@53dbd181 lelle]$ db2 "with T (x) as (values
('1.0'),('4.5'),('No'),('-3.0')) select sum(decimal(x,2,1)) from T where
x between '0' and '9' or x between '-0' and '-9'"
1
---------------------------------
2.5
/Lennart