How to get a float result by dividing two integer values using T-SQL?

后端 未结 8 1793
暖寄归人
暖寄归人 2020-11-22 15:39

Using T-SQL and Microsoft SQL Server I would like to specify the number of decimal digits when I do a division between 2 integer numbers like:

select 1/3
         


        
8条回答
  •  温柔的废话
    2020-11-22 15:57

    Looks like this trick works in SQL Server and is shorter (based in previous answers)

    SELECT 1.0*MyInt1/MyInt2
    

    Or:

    SELECT (1.0*MyInt1)/MyInt2
    

提交回复
热议问题