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)
 Ask for Sql Top..

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-12-06 : 08:32:00
Thu writes "Hi.
I read this topic :
http://www.sqlteam.com/item.asp?ItemID=566
and i did it, but i have one proble. please help me
When i have a big table (5000 records), i want to select some records which between a..d. For example, i want to select 30 students which have the posision from 500 to 550. I used the select command :
Select top 550 * from st_table where id not in (select top 500 id from st_table order by poss desc) order by poss desc

It's OK, but it take along time to do that and sometime it cannot display result.

Please help me ???????"

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-06 : 08:41:41
shouldn't that be
Select top 30 * from st_table where id not in (select top 500 id from st_table order by poss desc) order by poss desc

try
Select top 30 * from (select top 530 * from st_table order by poss desc) a order by poss



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -