473,387 Members | 1,779 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,387 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 3170
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.