Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Count Help

Status
Not open for further replies.

excalibur78

IS-IT--Management
Jan 3, 2001
66
US
I'm running a dynamic select top x command where x can be more records then are in the recordset. x can be 600 and when you execute the select top 600 ..... it only returns say 200 records since that's all there is. Now I run the same select and only want 50 records. How can I store the actual record count? I tried "select top 50 count(*) ...." and it only gives me the the max recordset number in this example 200 even tho I said top 50.


Thanks
 
Not sure I exactly get what you want but what about something like this


select count(*) from yourtable where yourkey=ANY
(select top 50 yourkey from yourtable)

Andy
 
If I understandw hat you are getting at, try somethinfg like this (I used one of my tables as an example, use your own table and field names)

select count(*) from (select top 50 AirportID from Airport) AP

The AP is a derived table alias you could use any name you wanted here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top