<?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: How to find missing values in a sequence with SQL</title>
	<atom:link href="http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Mo' Kassab</title>
		<link>http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/#comment-19849</link>
		<dc:creator>Mo' Kassab</dc:creator>
		<pubDate>Mon, 23 Jan 2012 06:56:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=57#comment-19849</guid>
		<description>Thank you Steven.
Regards,
Mo&#039; Kassab</description>
		<content:encoded><![CDATA[<p>Thank you Steven.<br />
Regards,<br />
Mo&#8217; Kassab</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steven</title>
		<link>http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/#comment-19844</link>
		<dc:creator>steven</dc:creator>
		<pubDate>Sat, 21 Jan 2012 18:28:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=57#comment-19844</guid>
		<description>lovely, years after and still a great post. Good job thank you</description>
		<content:encoded><![CDATA[<p>lovely, years after and still a great post. Good job thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/#comment-19728</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Tue, 15 Nov 2011 21:30:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=57#comment-19728</guid>
		<description>Does anybody know how to alias the subquery solution correctly so that it runs in Teradata?

select start, stop from (
  select m.id + 1 as start,
    (select min(id) - 1 from sequence as x where x.id &gt; m.id) as stop
  from sequence as m
    left outer join sequence as r on m.id = r.id - 1
  where r.id is null
) as x
where stop is not null;</description>
		<content:encoded><![CDATA[<p>Does anybody know how to alias the subquery solution correctly so that it runs in Teradata?</p>
<p>select start, stop from (<br />
  select m.id + 1 as start,<br />
    (select min(id) &#8211; 1 from sequence as x where x.id &gt; m.id) as stop<br />
  from sequence as m<br />
    left outer join sequence as r on m.id = r.id &#8211; 1<br />
  where r.id is null<br />
) as x<br />
where stop is not null;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mo' Kassab</title>
		<link>http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/#comment-19684</link>
		<dc:creator>Mo' Kassab</dc:creator>
		<pubDate>Sat, 08 Oct 2011 05:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=57#comment-19684</guid>
		<description>Dear Lalit,

Using the above code I posted earlier on 7-May, I have made some modifications to tune in with your requirements.

Check the code below:

declare
cursor seq_crs is
select to_number(substr(code,-2)) as code from fast order by code;
x number; /*start with minimum number*/
begin
select min(to_number(substr(code,-2))) into x from fast;
for rec in seq_crs loop
while x &lt;= rec.code loop
if x != rec.code then  
/* if x doesn&#039;t equal rec.code then ...*/
dbms_output.put_line(’5G’&#124;&#124;to_char(x,’fm0999?));
end if;
x := x+1;
end loop;
end loop;
end;

my result came out to be:
anonymous block completed
5G0010
5G0015
5G0016
5G0017
5G0019

Hope that solved your problem.

Regards,
Kassab</description>
		<content:encoded><![CDATA[<p>Dear Lalit,</p>
<p>Using the above code I posted earlier on 7-May, I have made some modifications to tune in with your requirements.</p>
<p>Check the code below:</p>
<p>declare<br />
cursor seq_crs is<br />
select to_number(substr(code,-2)) as code from fast order by code;<br />
x number; /*start with minimum number*/<br />
begin<br />
select min(to_number(substr(code,-2))) into x from fast;<br />
for rec in seq_crs loop<br />
while x &lt;= rec.code loop<br />
if x != rec.code then<br />
/* if x doesn&#039;t equal rec.code then &#8230;*/<br />
dbms_output.put_line(’5G’||to_char(x,’fm0999?));<br />
end if;<br />
x := x+1;<br />
end loop;<br />
end loop;<br />
end;</p>
<p>my result came out to be:<br />
anonymous block completed<br />
5G0010<br />
5G0015<br />
5G0016<br />
5G0017<br />
5G0019</p>
<p>Hope that solved your problem.</p>
<p>Regards,<br />
Kassab</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mo' Kassab</title>
		<link>http://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/#comment-19683</link>
		<dc:creator>Mo' Kassab</dc:creator>
		<pubDate>Sat, 08 Oct 2011 05:22:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=57#comment-19683</guid>
		<description>Dear Lalit,

Using the above code I posted earlier on 7-May, I have made some modifications to tune in with your requirements.

Check the code below:

declare
cursor seq_crs is
select to_number(substr(code,-2)) as code from fast order by code;
x number; /*start with minimum number*/
begin
select min(to_number(substr(code,-2))) into x from fast;
for rec in seq_crs loop
while x &lt;= rec.code loop
if x  rec.code then
dbms_output.put_line(’5G’&#124;&#124;to_char(x,’fm0999?));
end if;
x := x+1;
end loop;
end loop;
end;

my result came out to be:
anonymous block completed
5G0010
5G0015
5G0016
5G0017
5G0019

Hope that solved your problem.

Regards,
Kassab</description>
		<content:encoded><![CDATA[<p>Dear Lalit,</p>
<p>Using the above code I posted earlier on 7-May, I have made some modifications to tune in with your requirements.</p>
<p>Check the code below:</p>
<p>declare<br />
cursor seq_crs is<br />
select to_number(substr(code,-2)) as code from fast order by code;<br />
x number; /*start with minimum number*/<br />
begin<br />
select min(to_number(substr(code,-2))) into x from fast;<br />
for rec in seq_crs loop<br />
while x &lt;= rec.code loop<br />
if x  rec.code then<br />
dbms_output.put_line(’5G’||to_char(x,’fm0999?));<br />
end if;<br />
x := x+1;<br />
end loop;<br />
end loop;<br />
end;</p>
<p>my result came out to be:<br />
anonymous block completed<br />
5G0010<br />
5G0015<br />
5G0016<br />
5G0017<br />
5G0019</p>
<p>Hope that solved your problem.</p>
<p>Regards,<br />
Kassab</p>
]]></content:encoded>
	</item>
</channel>
</rss>

