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)
 TOP Values Range

Author  Topic 

cardgunner

326 Posts

Posted - 2008-02-29 : 08:54:59
My company has requested me to give them the top 20 customers in our database. Now problem I can do that.

Next week they are going to ask me for the the next 20. I could count down or put it in an excel and count the rows. However that that is not a great solution.

Is there a statement that says top 20 to 30?
or
Is there a way to assign a temp ranking to the records and then I could select use tmp.rank between 20 and 30?

I hope this makes sense?

Card Gunner

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-29 : 08:56:32
Add identity column to the table, then you can query range of records using identity column.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cardgunner

326 Posts

Posted - 2008-02-29 : 09:07:30
Identity column? I will search to find out what this is cause it sounds right.

However when you say add to the table the temp table right?


Card Gunner
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-29 : 09:09:43
You need some kind of paging.
See http://weblogs.sqlteam.com/peterl/archive/2008/02/19/Efficient-pagination-for-large-set-of-data.aspx

It is for SQL Server 2005, but you can hardwire the top values to fit your requirements.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -