Druid SQL division query behavior

select sum(column1) , SUM(column2), sum(column1)/ SUM(column2) , (sum(column1) + SUM(column2)) as aliasColumn from datasource where AND __time>=‘2020-06-30T00:00:00’ and __time<=‘2020-07-30T00:00:00’ GROUP BY columnId

Above query when executed returns 1,3,0,4 respectively when it should have been 1,3,1/3,4 respectively .

Any reason why its behaving that way? Have attached the screenshot of the result too.

Thanks in advance

Integer division
Both operands are integers so result gets rounded to integers
Try casting them to float,decimal etc types. Then results should be 0.3333

Thanks Visakh! This is different behavior from SQL queries in SQL DBs

Nope Vindhya
Not all
In some RDBMS also the behavior is the same :slight_smile:
For example below result is from SQL Server

image.png

As you see, here also it undergoes integer arithmetic and returns result as integer

Regards
Visakh