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
Select where number equals Infinity
提问by BnJ
In SQL, how to select the rows of a table where a column (datatype : number
) equals Infinity
on 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 infinite
floating 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 infinite
clause is also an option.
更新:感谢Alex,该is infinite
条款也是一种选择。
I am on 12.1.0.1
.
我在12.1.0.1
。
The same query with is infinite
clause :
带有is infinite
子句的相同查询:
SQL> WITH DATA AS(
2 SELECT 1/0F COL FROM DUAL)
3 SELECT * FROM data WHERE col is infinite
4 /
COL
----------
Inf