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
 Transact-SQL (2000)
 select statement.......

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2002-02-27 : 20:15:08

Ok, im driving myself nuts over this

I want to grab just the top userID. So in this case I would like to bring back the top 3 rows (userID 422), then after I delete those I would like to bring back the 4th and 5th row (both userid 426)


userid X Y

422 1 1
422 2 1
422 3 1
426 1 1
426 2 1
435 1 1
435 2 1
436 2 1

I hope you catch my drift.. I swear I had this working and overwrote the SP....


Thanks alot!!!


Tigger
Yak Posting Veteran

85 Posts

Posted - 2002-02-27 : 20:19:42
Does this do what you want?

select *
from <table name>
where userid = (select top 1 userid from <table name>)

Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-02-28 : 19:46:55
Be sure to add an Order By clause to Tigger's answer.

Or, I believe the following also does what you want, without a subquery...

SELECT TOP 1 WITH TIES *
FROM tblSample
ORDER BY UserID

------------------------
GENERAL-ly speaking...

Edited by - AjarnMark on 02/28/2002 19:47:18
Go to Top of Page
   

- Advertisement -