# Percentages in Starburst Enterprise IDE

**URL:** <https://www.starburst.io/community/forum/t/percentages-in-starburst-enterprise-ide/514>\
**Category:** SQL\
**Created:** [May 14, 2024, 8:04pm UTC](https://www.starburst.io/community/forum/t/percentages-in-starburst-enterprise-ide/514 "2024-05-14T20:04:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanoosha](https://www.starburst.io/community/forum/user_avatar/www.starburst.io/sanoosha/32/238_2.png) [@sanoosha](https://www.starburst.io/community/forum/u/sanoosha)\
**Post date:** [May 14, 2024, 8:04pm UTC](https://www.starburst.io/community/forum/t/percentages-in-starburst-enterprise-ide/514/1 "2024-05-14T20:04:12Z")

</div>

Whenever I do a division of integers on Starburst, the results are always rounded either to 0 or 1. I would like the casting to automatically to set to decimals when this division is done. Additionally I need the DIV0 function to handle divisions by 0.

---

<div class="post-metadata">

**Author:** ![lester](https://www.starburst.io/community/forum/user_avatar/www.starburst.io/lester/32/138_2.png) [@lester](https://www.starburst.io/community/forum/u/lester)\
**Post date:** [May 14, 2024, 8:42pm UTC](https://www.starburst.io/community/forum/t/percentages-in-starburst-enterprise-ide/514/2 "2024-05-14T20:42:50Z")

</div>

TWO great questions in ONE post! Let’s see if I can help.

First up is the need for decimal places.

`select 100 / 3 AS decimal_answer;`  
returns `3`

`select cast(100 AS double) / cast(3 AS double) as decimal_answer;`  
returns `33.333333333333336`

`select round(cast(100 AS double) / cast(3 AS double), 3) as decimal_answer;`  
returns `33.333`

Second up is the divide by 0.

`SELECT 100 / 0 AS div0_answer;`  
**blows up!**

`SELECT COALESCE(TRY(100 / 0), 0) AS div0_answer;`  
returns `0`

Please let me know if this doesn’t help.

---

<div class="post-metadata">

**Author:** ![simpligility](https://www.starburst.io/community/forum/user_avatar/www.starburst.io/simpligility/32/190_2.png) [@simpligility](https://www.starburst.io/community/forum/u/simpligility)\
**Post date:** [May 24, 2024, 3:37pm UTC](https://www.starburst.io/community/forum/t/percentages-in-starburst-enterprise-ide/514/3 "2024-05-24T15:37:27Z")

</div>

Just keep in mind that the result of a division by zero is NOT zero, but rather undefined, or even infinity. As such I suggest to be very careful about using that approach to return zero as the result.
