Exponential Value parsing in SQL
If you have exponential value in you column and and you want to concert into number or string then please use below function.
- Cast the value in double ( in some sql double is not supported then please try with float) but if the length is higher like Bigint or Long Int the use double.
- Use format_number function to convert exponential value to normal number. with precision.
- Cast again to convert into string to remove precision value.
- Use replace function to remove comma(',') between string.
Problem: col - 5.498342022637685E15
Solution:
SELECT replace(cast(format_number(cast(col_name as double),0) as string),',','') as alias from table_name
Result :- 5498342022637680
Comments
Post a Comment