Why does SQL Server round off results of dividing two integers?

后端 未结 6 1755
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 17:22

I have a table with a smallint column that contains percentages as whole numbers (i.e., 50, 75, 85, etc.)

When I divide this column by 100, as in

SEL         


        
6条回答
  •  春和景丽
    2020-12-03 17:50

    You're dividing 2 integers which results in another integer.

    It should possible to cast that way, too

    SELECT (50/100)::numeric;

提交回复
热议问题