I need to remove or replace an unwanted character (%) which is at the end of a string and then to cast the string to a decimal, because I need to get the sum of 2 fields named discount1 and discount2
The last combination I tried is:
replace ((p16.pa_value,'%','')CAST (p16.pa_value AS DECIMAL (3,0))) as discount2,
It seems to be super wrong as the CAST is inside of the replace statement
try this:
CAST (replace (p16.pa_value,'%','') AS DECIMAL (3,0)) as discount2
OK, I don't know why do you have three digits after decimal: DECIMAL (3,0) because if you convert to decimal it should be: decimal (10; how many zeros after ,) - more info here
Try this:
(cast(replace(p16.pa_value, '%','')  as decimal (10,2))) as discount
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With