Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Order of where clause matters!

Re: Order of where clause matters!

From: <wliu2_at_my-deja.com>
Date: 2000/05/26
Message-ID: <8gmmn2$nd2$1@nnrp1.deja.com>#1/1

In article <392edaa6_at_news>,
  "Patrick Joyal" <please.reply_at_to.the.newsgroup> wrote:
> You won't get the error, but you would get rows
> where col_a = 0 but you don't want them.

Not really. In the sql statement

   select *
   from my_table
   where stuff /* stuff that means "col_a" is never 0 */    and col_b/decode(col_a, 0, 1, col_a) > 10;

the first condition in the where clause requires that col_a is not 0.

>
> two safe ways to do it:
>
> Select * from my_table
> where decode (col_a, 0, 0, col_b / col_a) > 10 ;
>
> or
>
> (maybe slower 'cause it uses a subquery)
>
> select *
> from
> (
> Select * from my_table
> where col_a <> 0
> )
> Where col_b /col_a > 10 ;
>
> >
> >A workaround could be:
> >
> >select *
> >from my_table
> >where stuff /* stuff that means "col_a" is never 0 */
> >and col_b/decode(col_a, 0, 1, col_a) > 10;
> >
> >So you won't get the error.
> >
> >Wei
> >
> >
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri May 26 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US