Round to n Significant Figures in SQL

前端 未结 4 1536
-上瘾入骨i
-上瘾入骨i 2021-02-18 14:38

I would like to be able to round a number to n significant figures in SQL. So:

123.456 rounded to 2sf would give 120
0.00123 rounded to 2sf would give 0.0012
         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-18 14:42

    You could divide by 100 before rounding and then multiplying by 100...

提交回复
热议问题