AWS Athena - how to make long numbers more human readable

It happens that you have calculations in your queries. And the numbers returned can be a little to long for a human-reading.

I am working on some AWS CUR data, and I get a discount of 49.99999999999999%. No one will complain if I put that at 50%.

The answer is to use either

  • ROUND(YOUR_TOO_LONG_NUMBER) with only one parameter or
  • ROUND(YOUR_TOO_LONG_NUMBER, A_SHORT_NUMBER) with two parameters

Round, does what it says on the tin, it rounds the numnber to the closest integer)

SELECT ROUND(49.99999999999999)

Returns 50.0, Yeah

If you want to keep some numbers behind the dot (ie decimals) you can use ther version of ROUND() with two parameters. To keep 2 decimals use 2 as the second parameter.

SELECT ROUND(49.33333, 2)

Returns 49.33

comments powered by Disqus