How to convert integer to decimal in SQL Server query?

后端 未结 5 1849
孤独总比滥情好
孤独总比滥情好 2020-12-30 18:56

A column height is integer type in my SQL Server table. I want to do a division and have the result as decimal in my query:

Select (height/10) a         


        
5条回答
  •  醉话见心
    2020-12-30 19:14

    SELECT height/10.0 AS HeightDecimal FROM dbo.whatever;
    

    If you want a specific precision scale, then say so:

    SELECT CONVERT(DECIMAL(16,4), height/10.0) AS HeightDecimal
      FROM dbo.whatever;
    

提交回复
热议问题