Select where number equals Infinity

BnJ picture BnJ · Oct 1, 2014 · Viewed 20.4k times · Source

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

select * from MYTABLE where MYCOLUMN = Infinity;

Answer

Alex Poole picture Alex Poole · Oct 1, 2014

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:

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.