1

I have here a super uncleaned data (i must admit it -_-)

Field: Amount which is char

Values are '20 35' & '25..56'

How can i sum this with these two different value?

I can't used

 cast(replace("Amount",' ','.')  as DECIMAL) 

since it only applied in Amount with space.

Already correct the datatype of its field.

Please help me. TIA! :D

1 Answer 1

3

You can use a regular expression to replace non-digits with a decimal point:

select cast(regexp_replace('25sd  ss343', '[^\d]+', '.', 'g') as decimal)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this help, but it become whole number. from 25..56 it became 2556.. The result should be 25.56 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.