选择数字等于无穷大的位置

时间:2014-10-01 08:37:47

标签: sql oracle numbers infinity

在SQL中,如何在Oracle 10g上选择列(数据类型:number)等于Infinity的表的行?

select * from MYTABLE where MYCOLUMN = Infinity;

2 个答案:

答案 0 :(得分:10)

来自Laurent Schneider

select * from MYTABLE where MYCOLUMN = binary_double_infinity;

或者使用隐式演员,只需:

select * from MYTABLE where cast(MYCOLUMN as binary_double) = binary_double_infinity;

或使用the is infinite floating point condition

select * from MYTABLE where cast(MYCOLUMN as binary_double) is infinite;

我会附上一个SQL小提琴,但正如Laurent所说,"期待你的oracle客户端出现很多错误&#34 ;;这适用于SQL Developer,但SQL Fiddle会出现数字溢出。

答案 1 :(得分:2)

让我们先了解如何获得 Infinity

SQL> SELECT 1/0F COL FROM DUAL
  2  /

       COL
----------
       Inf

现在,让我们来看看比较:

SQL> WITH DATA AS(
  2  SELECT 1/0F COL FROM DUAL)
  3  SELECT * FROM data WHERE col = binary_double_infinity
  4  /

       COL
----------
       Inf

更新:感谢 Alex is infinite子句也是一个选项。

我在12.1.0.1

is infinite子句相同的查询:

SQL> WITH DATA AS(
  2  SELECT 1/0F COL FROM DUAL)
  3  SELECT * FROM data WHERE col is infinite
  4  /

       COL
----------
       Inf