You are here: Re: SQL Challenge - how to return a record set starting at a particular record? « MsSQL Server « IT news, forums, messages
Re: SQL Challenge - how to return a record set starting at a particular record?

Posted by Ed Murphy on 02/25/07 03:02

michealp@gmail.com wrote:

> I have a directory of user information. What I would like to do is
> allow someone to search for person X and then return not only the
> information for person X, but also the information for the next 15
> people following person X sorted alphabetically by lastname.
>
> So if someone searched for the lastname = "Samson", it would return:
>
> Samson, John
> Saxton, Greg
> Scott, Heather
> Sears, Rebecca
> .... (15 names following "Samson) ...
>
>
> How do you in SQL return a record set of X records starting at
> particular record (e.g. lastname = "Smith)?

set rowcount 15

select last_name, first_name
from the_table
where last_name >= 'Smith'
order by last_name

set rowcount 0

(I forget, how does/doesn't SELECT TOP 15 work in SQL 2K vs 2K5? I
haven't had occasion to need to remember.)

 

Navigation:

[Reply to this 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

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