Reply to Re: Retrieve next lowest number in mixed set

Your name:

Reply:


Posted by Zamdrist on 10/04/07 21:10

On Oct 4, 3:31 pm, "David Portas"
<REMOVE_BEFORE_REPLYING_dpor...@acm.org> wrote:
> "Zamdrist" <zamdr...@gmail.com> wrote in message
>
> news:1191525448.343516.292440@k79g2000hse.googlegroups.com...
>
>
>
> > Let's say I have a result set (records) containing numbers such as:
>
> > 0
> > 1
> > 2
> > 3
> > 9
> > 16
> > 21
> > 45
> > 100
> > 101
> > 102
> > 103
> > 104
> > 105
> > 106
>
> > How might someone write a procedure to get the next lowest number in
> > this sequence? In this case it would be: 4. Some combination of
> > Select, Min & When, I am sure, but it escapes me at the moment.
>
> > Thoughts? Thanks...
>
> SELECT MIN(x)+1 x
> FROM tbl t
> WHERE NOT EXISTS
> (SELECT x
> FROM tbl
> WHERE x = t.x+1);
>
> --
> David Portas

Thanks!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация