Friday, January 24, 2014

Predicate N = N-1 returns rows?

Following a tweet from  "Quiz Q for the day: "select * from T where N = N - 1;" returns rows - how?", I did a small setup to try to answer the question.

SQL> select banner from v$version where rownum=1;

BANNER
----------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

--number

SQL> drop table tt
  2  ;

Table dropped.

SQL> create table tt as select 1/0f N from dual;

Table created.

SQL> desc tt;
 Name                                      Null?    Type
 ----------------------------------------- -------- -------------
 N                                                  BINARY_FLOAT

SQL> select * from tt where N=N-1;

         N
----------
       Inf

SQL>

No comments:

Post a Comment