Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to get the 11th to the 20th rows out of 100 rows

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-03-19 : 08:30:28
Elizabeth writes "Hello,
Can you please help me to get the 11th to the 20th rows of for this example below.
Here is the example of my script:

SELECT d.docDescrpt AS docDescrpt, d.clientID AS clientID, d.camDocID AS camDocID, d.camSourceID AS camSourceID,
d.docName AS docName, d.pageLink AS pageLink, d.docSize AS docSize, d.isStaticDoc as isStaticDoc, d.createdDate AS createdDate, ISNULL(d.camActionID,0) AS camActionID,
ISNULL(d.camResultID,0) AS camResultID, d.createdUserID AS createdUserId, RTRIM(ISNULL(u.First+u.Last,'')) AS userName, RTRIM(ISNULL(u.company,'')) AS company, u.camUserID AS camUserID
FROM camDocument d LEFT JOIN camUser u ON d.camSourceID = u.camUserID
WHERE d.clientID = @clientID AND d.camDocID NOT IN(SELECT camDocId FROM CamProspectDoc) ORDER BY d.docDescrpt, d.createdDate DESC

I have a sample of the way to do it for a simple script without join. Here it is:
SELECT TOP 10 x.name, x.population FROM (
SELECT TOP 20 name, population FROM cia
ORDER BY population DESC) x
ORDER BY x.population ASC

But, I have a more complex script. And, also I will have to build dynamic script as well.


Thank you very much for your help.
Elizabeth"

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2004-03-19 : 08:35:59
You should go back to the basics! In a tiered architecture, the display is done in the front end. The database backend simply retrieves data and returns it in a particular order to the next tier.

However, if you *want* to do this in TSQL, search this site for paging. Returns several hits.



--Frank
http://www.insidesql.de
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-03-19 : 18:24:21
quote:
You should go back to the basics! In a tiered architecture, the display is done in the front end
I must disagree with this statement if the question is related to paging a resultset for the presentation tier. Many tests have proven that this is the most efficient method for paging a resultset.

If you have a recordset it is best to select the results you will be displaying for that page rather than send the entire resultset across the network to another tier for further selective page processing.

Though I do agree with Frank that a search will produce some very good examples here on SQLTeam for performing this.
Go to Top of Page
   

- Advertisement -