I haven't actually tested this, but how about something like: -

select count(distinct(b.num))
from range a, numbers b
where b.num >= a.begin
and b.num <= a.end
/

--
David Lord

> -----Original Message-----
> From: oracle dba [mailto:[EMAIL PROTECTED]]
> Sent: 22 February 2002 04:03
> To: Multiple recipients of list ORACLE-L
> Subject: sql question
> 
> 
> Hi all,
> 
> I have a SQL question.  Suppose I have a table called RANGE looks like
> this:
> 
> begin     end
> 1         9
> 10        19
> 20        29
> 
> Then I have a table NUMBERS that's full of bunch of numbers like this:
> 
> num
> 1
> 2
> 3
> 4
> ...
> 98
> 99
> 100
> 
> I want to write a SQL that returns the number that are within
> the ranges defined in the RANGE table.  So number 1 through 29
> should be returned.
> 
> Can someone help me with this?  Thanks.
> 
> Rich
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> -- 
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> -- 
> Author: oracle dba
>   INET: [EMAIL PROTECTED]
> 
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
> 


**********************************************************************
This message (including any attachments) is confidential and may be 
legally privileged.  If you are not the intended recipient, you should 
not disclose, copy or use any part of it - please delete all copies 
immediately and notify the Hays Group Email Helpdesk at
[EMAIL PROTECTED]
Any information, statements or opinions contained in this message
(including any attachments) are given by the author.  They are not 
given on behalf of Hays unless subsequently confirmed by an individual
other than the author who is duly authorised to represent Hays.
 
A member of the Hays plc group of companies.
Hays plc is registered in England and Wales number 2150950.
Registered Office Hays House Millmead Guildford Surrey GU2 4HJ.
**********************************************************************

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Lord, David - CSG
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to