I am new to snowflake and I am trying to write an SQL query to roundup values in a different way from the usual way. My query is able to round up to 2 decimal places
SELECT
"ID",
round("Cash", 2) AS "Balance",
"Currency"
FROM
"lex"
where "ID" = 101
in cases where cash = 100.065
it is rounded to 100.07
which is good.
I also want to round up cash = 100.061
to 100.07
Is this doable
CodePudding user response:
Perhaps a simple method is simply adding a value of 0.005 when rounding:
round(cash 0.005, 2)
EDIT: But you may need a case statement that looks at the 3rd digit after the decimal, and if a 0, then don't add 0.005. Just depends on your data and use case for rounding up.
CodePudding user response:
CEIL function should do that but it will round up any value so be careful with your precision
https://docs.snowflake.com/en/sql-reference/functions/ceil.html