Link to home
Start Free TrialLog in
Avatar of EVision
EVision

asked on

Return a select # records in an SQL

Is there a way to return the first x number of records for an SQL using MS SQL 6.5?  For example, in MS Access, I can request 'select Top 10 from Authors'.  
Avatar of kdimmock
kdimmock

SET ROWCOUNT 10
SELECT * FROM AUTHORS
SET ROWCOUNT 0
Avatar of EVision

ASKER

You are correct, but I did not give enough information.  I'm writing a TSQL statement and need to request

WHERE Person_ID not in ('Top 10 people ids from another SQL')

.therefore ROWCOUNT does not work.
Avatar of EVision

ASKER

I need to ask...

WHERE Person_ID not in ('Top 10 person ids from another SQL')
ROWCOUNT will not work.
Avatar of EVision

ASKER

Is it possible to use a server-side open cursor within an IN statement?
couldn't you create a temp table corresponding to the sub query with only 10 rows?
Avatar of EVision

ASKER

Possible, but inefficient.  It's for a bid agent on auction-type site.  For each insert in BIDS, I need to see if anyone has a MAX_ALLOWED_BID greater than the current lowest winning bid and not already a winner.  I'm trying to determine if the person is already a winner (TOP n Persons).  It's possible we may have 100 inserts a minute.  Too many times a temp table is created & deleted.  Any ideas???
Now I'm losing the plot!  Show me a cut down (but now pseudo) version of the SQL as you'd have written in access
typo:
Now I'm losing the plot!  Show me a cut down (but NOT pseudo) version of the SQL as you'd have written in access

in english, how would you define a winner?  eg, does "the top N persons" mean the same thing as "the N highest bidders"?  please give the names of the pertinent tables/columns.
Avatar of EVision

ASKER

There is a table Bids that has Auction_Code, Bidding_Member_Code and Price_Per_Unit.  I want to know the N highest bids for Auction_Code X.
ASKER CERTIFIED SOLUTION
Avatar of doubas
doubas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial