SQL比较第三个数字aftee小数点

时间:2016-11-11 05:03:21

标签: sql sybase

我想从myTable中选择myNum,其中myNum的小数点后第3个数字大于0。

所以

123.456将被退回。

123.450不会。

(SYBASE)

1 个答案:

答案 0 :(得分:1)

SELECT myNum
FROM myTable
WHERE FLOOR(myNum*1000) % 10 > 0

<强>解释

看见是相信的,所以给定输入123.456

myNum*1000 = 123456.xx   (possibly data last 3rd decimal place)
FLOOR(myNum*1000) = 123456
FLOOR(myNum*1000) % 10 = 6, which is greater than zero