Reputation: 7233
I have a column, called net_amount, it contains values like 244,98. Its a varchar column. When I try to sum it using the sum function, it only sums the 244 and skipts the decimal places. I tried casting it to decimal like this:
select cast(net_amount as decimal) from mytable
This skips the decimal places as well ... any idea what might be wrong?
Thanks!
Upvotes: 0
Views: 3696
Reputation: 49049
You could use REPLACE to replace comma to dot:
SELECT REPLACE('244,98', ',', '.') * 1
or you can use CAST like this:
cast(REPLACE(net_amount, ',', '.') as decimal(8,2))
Upvotes: 3