'SQL Divide Function not working in Metabase

In my Metabase, I wrote a query SELECT 10/5 It showing a result 2.000000000 which is correct.

But When I wrote SELECT 5/10 It showing a result 0.000000000. The result should show 0.500000000.

Can you explain it? Why divide function is not working?



Solution 1:[1]

Metabase can parse SQL different ways. It depends on connector type.

But in most cases, the result depends on the data type.

Your example uses integer division, because both of operands are integer.

You can just try to change the data type enter image description here

Solution 2:[2]

It is rounding off the value,

Like for select 7/5 it will print 1.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fedyanint Timofey
Solution 2 Dhananjay Dahiya 2k19ae020