SQL Server truncates decimal points of a newly created field in a view

前端 未结 3 1939
故里飘歌
故里飘歌 2020-12-09 21:22

I have a view in SQL server, something like this:

select 6.71/3.41 as NewNumber

The result is 1.967741 (note 6 decimal points)

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 21:30

    This is a bit workaround, but I think it's worth a note.

    select ((6.71*10000)/(3.41*10000)) as NewNumber
    

    This query:

    SELECT 6.71/3.41, ((6.71*1000000)/(3.41*1000000)) as NewNumber
    

    returns:

    1.967741    1.96774193548387
    

提交回复
热议问题