Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Challenging query problem deailing with %s

Status
Not open for further replies.

cojiro

MIS
Mar 20, 2003
62
US
I don't really know what direction to go with on this problem. Here is the situation:
I have a list of transactions with the UserIDs of the employees that entered the transactions for a given month. for auditing purposes I need to retrive a random 10% of the transactions entered by each individual (i.e. if someone entered 100 transactions I would want 10 random transactions from that userID). In the end I should have roughly 10% of all the original transactions with at least one transaction listed for each person (i.e. if someone entered only 2 transactions, I would still want to return 1 even though it is more than 10%).

Each transaction is a record in an Access database witch looks like this:

TRANSACTION USERID
wjeksl3432 U52P93
ksken23834 U52P93
kdlwc92721 U89K25

Does anyone know the best way of going about this?

Thanks!
 
(Q) How can I return Random records from a table?

(A) Paste the following function in a new module.

'************ Code Begin ***********
'Code courtesy of
'Joe Foster
Function Randomizer () As Integer
Static AlreadyDone As Integer
If AlreadyDone = False Then Randomize : AlreadyDone = True
Randomizer = 0
End Function
'************ Code End *************
Now to get 100 questions picked at random:

select top 100 mytable.*from mytable
where randomizer() = 0
order by rnd(isnull(mytable.question) * 0 + 1)

'from:
'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top