You are here: Re: How To Return A "Range Of Rows"?? « MsSQL Server « IT news, forums, messages
Re: How To Return A "Range Of Rows"??

Posted by Erland Sommarskog on 04/12/07 21:10

pbd22 (dushkin@gmail.com) writes:
> I "am" using 2005 and the solution looks much easier than the 2000
> alternatives.
> I am not sure why, but the second message I posted in this thread was
> right after the first but it appeared after your response. Regardless,
> as you can see my queries are somewhat complicated and I am not quite
> sure how to apply your 2005 solution (OrdersCTE) to them. I am
> wondering if you could use one of my queries to demonstrate how it
> works (I hope I am not being too demanding)?
> It would help me get my mind wrapped around things.

WITH CTE (
SELECT <yourselectlistgoeshere>,
rownum = row_number() over( ORDER BY <yourorderbylisthere>)
FROM <yourfrom+joinshere>
WHERE <anywhereclauseyoumayhav>
)
SELECT <yourselectlisthereagain, nowwithoutaliases>
FROM CTE
WHERE rownum BETWEEN @first AND @last
ORDER BY rownum


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

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

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