Dear Mota:
The second quarter of the rows could be found as the last half of the
first half:
Select Top 50 percent *
FROM (SELECT Top 50 percent [RecID],[Name],[Spec]
from PrescribersTBL order by RecID)
ORDER BY RecID DESC
The third quarter would be approximately:
Select Top 33 percent *
FROM (SELECT Top 75 percent [RecID],[Name],[Spec]
from PrescribersTBL order by RecID)
ORDER BY RecID DESC
and the last:
Select Top 25 percent *
FROM (SELECT Top 50 percent [RecID],[Name],[Spec]
from PrescribersTBL order by RecID)
ORDER BY RecID DESC
Now, there are problems with this. The proportions are not exact. 33
percent is not exactly a third. It may omit some rows, especially if
there are many. Indeed, I would not want to guarantee that even 25
percent will be 1/4 of the records. If the total number or rows do not
divide exactly by 4 then you may still have gaps.
I recommend you first count the rows, then divide them into nearly equal
parts. Then use Top 999, where 999 is the number of rows instead of a
proportion. By taking the top 999 rows then the "bottom" 998 rows out of
the top 1997 rows, then the "bottom" 998 rows out of the top 2995 rows,
then the bottom 998 rows, you will have divided 3993 rows into four nearly
equal sets. You would have to control this with your own code so it comes
out, writing the SQL with the code and submitting the query text.
Not simple, but it's the best I know.
Tom Ellison
Mota said:
Hi;
We want to devide records of a table to 4 equal parts and in each step
work on one part of them.For now,i can just select the first part,using
this query:
"Select Top 25 percent [RecID],[Name],[Spec] from PrescribersTBL order by
RecID"
Where field RecID is the Primary Key.
How to select the 2nd,3rd and 4th part (25 percent) of this table?(that
needs 3 more queries)
Any help is so much appreciated.
Thank you.