Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Group of Random Records

Author  Topic 

nschultz
Starting Member

3 Posts

Posted - 2005-10-21 : 15:24:20
I am storing data for a "random transaction survey" in Access based on the sevices completed by tellers.

I want no more than 3 randomly selected surveys to be sent out per teller id. I have a table that has columns that look like this:

TELLERID|CUSTNAME|CUSTTRANSTYPE

616|JIM|WITHDRAWAL
616|LISA|DEPOSIT
616|BILL|PAYMENT
616|SARA|WITHDRAWAL
34|NATE|DEPOSIT
34|ZACK|DEPOSIT
34|AMY|DEPOSIT
34|VINCE|DEPOSIT
34|LAURA|DEPOSIT
57|ERIC|DEPOSIT
57|BONNIE|DEPOSIT
8|TED|DEPOSIT
7|JEROME|DEPOSIT
7|SALLY|DEPOSIT

The result needs to be random 3 records per teller. Sample result:


616|JIM|WITHDRAWAL
616|LISA|DEPOSIT
616|SARA|WITHDRAWAL
34|NATE|DEPOSIT
34|VINCE|DEPOSIT
34|LAURA|DEPOSIT
57|ERIC|DEPOSIT
57|BONNIE|DEPOSIT
8|TED|DEPOSIT
7|JEROME|DEPOSIT
7|SALLY|DEPOSIT

This is what I've tried:

Select top 3 TELLERID, CUSTNAME, CUSTTRANSTYPE
from Table
where TellerID = 616
order by rnd(TELLERID)

This statement only gets 3 random records for "616". I want 3 for all unique Teller ID's

Any help?

Nate

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-22 : 00:55:12
Refer point 2 here
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nschultz
Starting Member

3 Posts

Posted - 2005-10-25 : 19:36:32
Since I'm just a beginner. Can you explain pt. two e.g. how it works?

Nate
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-26 : 01:43:40
Did that work?
In that blog ask your question by posting it as comment

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nschultz
Starting Member

3 Posts

Posted - 2005-10-26 : 16:06:50
No it doesn't work. It's not something that will work in Access. I need to know how to do this in Access because that is my only availabe resource.

Nate
Go to Top of Page
   

- Advertisement -