oracle 选择数字等于无穷大的地方

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26137332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:32:30  来源:igfitidea点击:

Select where number equals Infinity

sqloraclenumbersinfinity

提问by BnJ

In SQL, how to select the rows of a table where a column (datatype : number) equals Infinityon Oracle 10g ?

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

select * from MYTABLE where MYCOLUMN = Infinity;

回答by Alex Poole

From Laurent Schneider:

来自洛朗施耐德

select * from MYTABLE where MYCOLUMN = binary_double_infinity;

Or with an implicit cast, just:

或者使用隐式转换,只需:

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

Or using the is infinitefloating point condition:

或使用is infinite浮点条件

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

I would attach an SQL Fiddle, but as Laurent noted, "expect a lot of bugs with your oracle clients"; this works in SQL Developer, but SQL Fiddle gets a numeric overflow.

我会附上一个 SQL Fiddle,但正如 Laurent 指出的那样,“预计您的 oracle 客户端会出现很多错误”;这适用于 SQL Developer,但 SQL Fiddle 出现数字溢出。

回答by Lalit Kumar B

Let's see first how to get Infinity:

让我们先看看如何获​​得Infinity

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

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

Now, let's look at the comparison :

现在,让我们看一下比较:

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

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

Update: Thanks to Alex, the is infiniteclause is also an option.

更新:感谢Alex,该is infinite条款也是一种选择。

I am on 12.1.0.1.

我在12.1.0.1

The same query with is infiniteclause :

带有is infinite子句的相同查询:

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

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