在查询中使用双精度

时间:2017-02-14 17:19:21

标签: sql postgresql

我想使用users.id列查询表格,但是当我尝试

double precision

我没有结果。

select * from foo where bar > 2

什么都没有!当我尝试

select * from foo where bar < 2

我可以看到那里的所有记录。有些值类似于select bar from foo1.31744579794415e-08等等。

已经尝试4.82082769315891e-08bar < 2.0

我做错了什么?

1 个答案:

答案 0 :(得分:1)

此解决方案有效吗?

select * from foo where round(bar::numeric, 2) < 2 

但我很惊讶,因为所有这些断言都是真的:

select round(1.31744579794415e-08::numeric, 2) < 2 
select 1.31744579794415e-08::numeric < 2 
select 1.31744579794415e-08 < 2 

你确定没有别的吗?