473,394 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

get 10% random records out of 2000 records

anyone know how can i get a 10% random records out of 2000 records?

2000 is only an example and it will vary anytime.

i want to create a report out of this 10%

thanks in advance
Nov 12 '05 #1
3 3172
I don't know the syntax off the top of my head, but how about something like...

Copy the table to a new table (so the original is not irrevocably fragged)
NumRecords = # records in this table
TenPercent = (NumRecords * .1) \ 1 ' Use this as the outer limit of your loop

for K = 1 to TenPercent
RandRecord = a random number between 1 and NumRecords
Go To RandRecord 'go to that row
Pick up relevant data, store to array (or write to a new table)
Delete row #RandRecord 'to prevent this record from future selection
NumRecords = # records in this table 'reset this number to reflect
'remaining number of records
next K

jaYPee <hi******@yahoo.com> wrote in message news:<a7********************************@4ax.com>. ..
anyone know how can i get a 10% random records out of 2000 records?

2000 is only an example and it will vary anytime.

i want to create a report out of this 10%

thanks in advance

Nov 12 '05 #2
Bri
JayPee,

Here is the SQL for a query that will select a random 10% of the records:

SELECT TOP 10 PERCENT MyTable.*, Rnd(aNumericField) AS RandSort
FROM MyTable
ORDER BY Rnd(aNumericField)

Making the RND function use a field in the table as the seed makes the
function get called for each record rather than just once. The field
used as the seed must be numeric and its value should be different for
each record. I usually use the Autonumber PK field that exists in most
tables.
Bri
jaYPee <hi******@yahoo.com> wrote in message
news:<a7********************************@4ax.com>. ..
anyone know how can i get a 10% random records out of 2000 records?

2000 is only an example and it will vary anytime.

i want to create a report out of this 10%

thanks in advance


Nov 12 '05 #3
Thank you very much. this is really what i need.

On Tue, 06 Apr 2004 17:39:24 GMT, Bri <no*@here.com> wrote:
JayPee,

Here is the SQL for a query that will select a random 10% of the records:

SELECT TOP 10 PERCENT MyTable.*, Rnd(aNumericField) AS RandSort
FROM MyTable
ORDER BY Rnd(aNumericField)

Making the RND function use a field in the table as the seed makes the
function get called for each record rather than just once. The field
used as the seed must be numeric and its value should be different for
each record. I usually use the Autonumber PK field that exists in most
tables.
Bri
jaYPee <hi******@yahoo.com> wrote in message
news:<a7********************************@4ax.com> ...
anyone know how can i get a 10% random records out of 2000 records?

2000 is only an example and it will vary anytime.

i want to create a report out of this 10%

thanks in advance


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Keith Griffiths | last post by:
I'm trying to do a search under a set criteria followed by a selection of random entries meeting this criteria. But I don't seem to be able to achieve this. The idea being to search on say...
3
by: Wim Roffil | last post by:
Hi, When I do a select with a limit I get always the same records. Usually this is the desidered effect. But now I want to do a random select. So every time I do a select I should get a...
1
by: Manton | last post by:
Access 2000. I have a field in a table (tbl_data entry) which has a field called Free and another field called SD (containing 2 options: 5 and 6) The Free field is a yes/no format. I'd like to...
3
by: jaYPee | last post by:
anyone know how can i get a 10% random records out of 2000 records? 2000 is only an example and it will vary anytime. i want to create a report out of this 10% thanks in advance
4
by: yf | last post by:
A KB article "http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells that the maximum number of records that a table may hold if the PRIMARY key data type is set to AUTONUMBER is...
2
by: IceCube | last post by:
Hello, I would like to select/filter at random 30 records out of an Access-table of 1500 records. I know the option "Top" which gives me the possibility to see the 30 first records of the table...
2
by: VB Programmer | last post by:
I am interested to hear your suggestions on this... I have a table full of survey questions. The questions are individually classified as priority 1, 2 or 3. (Priority 1 means the question...
9
by: Jeremy | last post by:
I have a situation where i am trying to run two query's and retrieve one record from each query, then using Union combine them into one recordset. The First Query is strait forward and should just...
7
by: FrankEBailey | last post by:
I'm not sure if this is a completely dumb question, but please humor me :) I have a table of records, called Records, each of which has a Category_ID that places it in a specific category; the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.