How to use bigquery round up results to 4 digits after decimal point?

后端 未结 2 449
小蘑菇
小蘑菇 2021-01-18 03:46

We don\'t have decimal data type in BigQuery now. So I have to use float

But

In Bigquery float division

0.029*50/100=0.014500000000000002

Alt

2条回答
  •  没有蜡笔的小新
    2021-01-18 04:13

    Note that this question deserves a different answer now.

    The premise of the question is "We don't have decimal data type in BigQuery now."

    But now we do: You can use NUMERIC:

    SELECT CAST('0.029' AS NUMERIC)*50/100
    
    # 0.0145
    

    Just make your column is NUMERIC instead of FLOAT64, and you'll get the desired results.

提交回复
热议问题