<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Question: how to generate a range between numbers?</title>
	<atom:link href="http://oraqa.com/2008/01/23/how-to-generate-range-between-numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2008/01/23/how-to-generate-range-between-numbers/</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Tue, 06 Jul 2010 14:28:12 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: mjb</title>
		<link>http://oraqa.com/2008/01/23/how-to-generate-range-between-numbers/comment-page-1/#comment-230</link>
		<dc:creator>mjb</dc:creator>
		<pubDate>Thu, 24 Jan 2008 14:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2008/01/23/how-to-generate-range-between-numbers/#comment-230</guid>
		<description>Ok, so I have a table that looks like this:
&lt;pre&gt;
SQL&gt; desc testit
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 OPERATOR_NAME                                      VARCHAR2(10)
 NUMBERS                                            VARCHAR2(50)
 LOC                                                VARCHAR2(10)

&lt;/pre&gt;
And, my input dataset looks like this:
&lt;pre&gt;
SQL&gt; select * from testit;

OPERATOR_N NUMBERS                                            LOC
---------- -------------------------------------------------- ----------
sony       9848930997-9848931000                              pune
o2         65432-65435                                        hyd
voda       369852-369855                                      mum
orange     9290988345-9290988345                              blore
&lt;/pre&gt;

One solution, though I&#039;m not convinced it&#039;s optimal, is this:
&lt;pre&gt;
SQL&gt; l
  1  with source_data as
  2  (select operator_name,
  3          substr(numbers,1,instr(numbers,&#039;-&#039;)-1) start_num,
  4          substr(numbers,instr(numbers,&#039;-&#039;)+1) end_num,
  5          loc
  6     from testit)
  7  select distinct operator_name,
  8                  start_num+level-1 numbers,
  9                  loc
 10    from dual,
 11         source_data
 12   connect by level &lt;=end_num-start_num+1
 13* order by 1,2,3
SQL&gt; /

OPERATOR_N    NUMBERS LOC
---------- ---------- ----------
o2              65432 hyd
o2              65433 hyd
o2              65434 hyd
o2              65435 hyd
orange     9290988345 blore
sony       9848930997 pune
sony       9848930998 pune
sony       9848930999 pune
sony       9848931000 pune
voda           369852 mum
voda           369853 mum
voda           369854 mum
voda           369855 mum

13 rows selected.

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Ok, so I have a table that looks like this:</p>
<pre>
SQL&gt; desc testit
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 OPERATOR_NAME                                      VARCHAR2(10)
 NUMBERS                                            VARCHAR2(50)
 LOC                                                VARCHAR2(10)
</pre>
<p>And, my input dataset looks like this:</p>
<pre>
SQL&gt; select * from testit;

OPERATOR_N NUMBERS                                            LOC
---------- -------------------------------------------------- ----------
sony       9848930997-9848931000                              pune
o2         65432-65435                                        hyd
voda       369852-369855                                      mum
orange     9290988345-9290988345                              blore
</pre>
<p>One solution, though I&#8217;m not convinced it&#8217;s optimal, is this:</p>
<pre>
SQL&gt; l
  1  with source_data as
  2  (select operator_name,
  3          substr(numbers,1,instr(numbers,'-')-1) start_num,
  4          substr(numbers,instr(numbers,'-')+1) end_num,
  5          loc
  6     from testit)
  7  select distinct operator_name,
  8                  start_num+level-1 numbers,
  9                  loc
 10    from dual,
 11         source_data
 12   connect by level &lt;=end_num-start_num+1
 13* order by 1,2,3
SQL&gt; /

OPERATOR_N    NUMBERS LOC
---------- ---------- ----------
o2              65432 hyd
o2              65433 hyd
o2              65434 hyd
o2              65435 hyd
orange     9290988345 blore
sony       9848930997 pune
sony       9848930998 pune
sony       9848930999 pune
sony       9848931000 pune
voda           369852 mum
voda           369853 mum
voda           369854 mum
voda           369855 mum

13 rows selected.
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
