SQL Query Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a datbase with 5,000,000 records. I need to work with records
1,000,000 to 2,000,000.

I see that Access assigned unique ID's to each record. Can I use this to
filter for the data I need ?

If so how would I do that ?

Thank you in advance.
 
In order to do this, you need a subquery to get the first 2 million records,
then you order them in descending order and select the top million records
from that recordset.

Try something like:

SELECT Top 1000000 T.*
FROM (SELECT TOP 2000000 *
FROM yourTable
ORDER BY ID ASC) as T
ORDER BY T.ID DESC
 
change the 2,000,000 value in the subquery to 3,000,000

If you don't really need to work with exactly a million records at a time,
you could simply use those ID values in your query criteria. Something like:

Select * from yourTAble
WHERE ID between 2000000 and 300000

If no records have been deleted from the table, then this should get you 1
million records. Otherwise, it will return those between those values that
have not been deleted.

HTH
Dale
 
Back
Top