>hi,
>thank you for reply,
>
>i don't say 3 tables ,i have one table have all records(area,days)
>
>choice 800 randomly from avery day for avery area,insert to new table
>
>thanks
I think you have already asked similar questions in other threads, right?
Let me try this.
If the table is very large, the following solution may be too slow. But for a reasonable amount of records, it might be fast enough.
The idea is to add a field with random information, to help in the random selection of data.
Assume your table is called "MyTable", and the fields are called "area" and "days". Area can have values 1, 2 or 3; you want exactly 800 records.
use MyTable
copy structure to TempResult
use TempResult in 0
select *, rand() * 0.000000 as random;
from MyTable;
into cursor Temp;
order by area, random
go top
for i = 1 to 3
select Temp
locate rest for area = i
copy next 800 to temp2 while area = i
select TempResult
append from temp2
next
Depending on the situation, other methods might be faster. For example, you might write a loop that creates a random record number in the range from 1 to reccount(), and copies one record at a time. If it is important that you don't get the same record twice, you might have to check for duplicates every time you copy a record.
HTH,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)