3 個答案
- 最新
- 最多得票
- 最多評論
1
Hi, it depends on what specifically do you want, with a similar example 0.6456524 and 3 decimals
- If you want to have a ceiling of the previous decimal value : 0.646 To do this you can use a UDF or this mathematic expression
CEIL((CAST(column1 AS double) / column2)*1000)/1000 as cvr
- if you want to have a floor of the previous decimal value : 0.645
FLOOR((CAST(column1 AS double) / column2)*1000)/1000 as cvr
- if you want to numerically round the previous decimal value : 0.646. To do this you can use
ROUND((CAST(column1 AS double) / column2), 3) as cvr
You can always refer to the Athena operations documentation here
已回答 2 年前
0
You can use ROUND(col, 3)
to round a number to three decimal points:
SELECT ROUND(CAST(column1 AS DOUBLE) / column2), 3) AS cvr
FROM my_table
已回答 2 年前