anybody know how can I convert the inconsistent value column (contain both number and text) into number?
like this 4.5M => 4500000, 7M => 7000000
I tried convert but it doesn’t give me an expected answer. Thank you so much
anybody know how can I convert the inconsistent value column (contain both number and text) into number?
like this 4.5M => 4500000, 7M => 7000000
I tried convert but it doesn’t give me an expected answer. Thank you so much
2
Answers
You can
CAST
the column into decimal then multiply the number by 1000 ifK
, 1000000 ifM
, and so on :In MySQL, logical operators evaluate to 1 (for TRUE) and 0 (for FALSE), we can use this as the following:
If you have units other than
M
, you can expand the query as the following:demo