Operator and condition precedence

From: Rich Jesse <rjoralist_at_society.servebeer.com>
Date: Tue, 8 Sep 2009 15:49:39 -0500 (CDT)
Message-ID: <ff320f68e536ea40875046cf06a2794d.squirrel_at_society.servebeer.com>

Hey all,

A coworker asks me about casting an NCHAR column to NUMBER in a query on (AIX), so I of course offer up the syntax of TO_NUMBER. Somewhat knowing the data, I warn that conversions on columns of all spaces will fail. But for some reason, this works:

select aa.stuff, bb.stuff
from table_a aa,

     table_b bb
where aa.col_1a = bb.col_1b
  and to_number(aa.col_2a) = bb.col_2b

  and aa.col_3a = bb.col_3b
  and aa.col_4b = bb.col_4b
  and aa.col_6a in ('YY','ZZ')
  and aa.col_2a > ' '
  and aa.col_5a <> bb.col_5b;

Looking at the docs:


...tells me that the above would attempt to convert an AA.COL_2A to a number before filtering it out from the AA.COL_2A > ' ' part, but it obviously doesn't. And there are known values of AA.COL_2A where it's all spaces.

The above statement works. My question is "How?"


Received on Tue Sep 08 2009 - 15:49:39 CDT

Original text of this message