Remove trailing zeros in decimal value with changing length

前端 未结 15 2894
醉话见心
醉话见心 2020-12-05 04:36

I have a procedure I am doing that displays odds but the client wants only significant digits to be shown. So, 1.50 would show as \'1.5\' and 1.00 would show as \'1\'.

15条回答
  •  爱一瞬间的悲伤
    2020-12-05 05:18

    Taking forward the answer provided by @fooquency, if the column is already declared as a DECIMAL with a non-zero value for D in DECIMAL(M, D), we do not need to perform the WHERE condition

    WHERE yourfield LIKE '%.%'
    

    as the values in the column will always contain D digits after the decimal dot (.)

提交回复
热议问题