Re: How To Return A "Range Of Rows"??
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Thu, 12 Apr 2007 21:10:42 +0000 (UTC)
pbd22 (dushkin@xxxxxxxxx) 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@xxxxxxxxxxxxx
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
.
- References:
- How To Return A "Range Of Rows"??
- From: pbd22
- How To Return A "Range Of Rows"??
- Prev by Date: ssis - Export to a file and Rename file
- Next by Date: Re: RESTORE DATABASE ... WITH PARTIAL
- Previous by thread: Re: How To Return A "Range Of Rows"??
- Next by thread: Re: How To Return A "Range Of Rows"??
- Index(es):
Relevant Pages
|