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: help with multiple BETWEEN statements

Re: help with multiple BETWEEN statements

From: David Fitzjarrell <oratune_at_msn.com>
Date: 13 Jan 2003 09:02:47 -0800
Message-ID: <32d39fb1.0301130902.d2a5d2b@posting.google.com>


This is incorrect in that it ignores the initial condion:

where rate = 'abc'

This should apply to the rest of the conditionals appended to it.

A correct solution would be:

          SELECT A  from table1
          where rate = 'abc'
          and     (code between '0100' and '0199'
          or     code between '4000' and '4499'
          or     code between '7000' and '7999'
          or     code between '9000' and '9499');

This enforces the conditions as expected, and allows for multiple ranges for the code column.

David Fitzjarrell

noodles_at_aol.com (Noodles) wrote in message news:<20030112185012.21504.00000430_at_mb-fm.aol.com>...
> I think you mean the following:
>
> SELECT A from table1
> where rate = 'abc'
> or code between '0100' and '0199'
> or code between '4000' and '4499'
> or code between '7000' and '7999'
> or code between '9000' and '9499';
>
> Xho is correct in the fact that you can't stisfy mutually exclusive conditions.
>
> Cliff
Received on Mon Jan 13 2003 - 11:02:47 CST

Original text of this message

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