Results 1 to 3 of 3
  1. #1
    haydenbl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    11

    Random Record pull

    I have two tables, one table “Data” has member(SUBSCRIBER_ID) data including service rep(UserName). Another table “ServCoord” has data including service rep and their manager. What I am trying to do is pull 5 random accounts per service rep. I can pull 5 random accounts, but not per service rep. I have currently 77 service reps. Is there any way I can pull 5 random accounts per service rep? Here is my starting point so far.



    SELECT TOP 385 [Data].SUBSCRIBER_ID, Rnd(1) AS Expr1, [Data].UserName, Rnd(Len([UserName])) AS Expr2
    FROM ServCoord INNER JOIN [Data] ON ServCoord.ServCoord = [Data].UserName
    GROUP BY [Data].SUBSCRIBER_ID, Rnd(1), [Data].UserName, Rnd(Len([UserName])), [Data].SUBSCRIBER_ID, [Data].UserName
    HAVING ((([Data].UserName)<>"NULL"))
    ORDER BY [Data].UserName, [Data].SUBSCRIBER_ID;

    Thanks for your help in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Here is info on pulling so many records per group. http://allenbrowne.com/subquery-01.html#TopN

    No idea how to randomize that.

    Bing: SQL random records group
    http://stackoverflow.com/questions/2...rds-from-group
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    There is a sample for pulling random records per group at https://www.accessforums.net/tutoria...oup-41737.html

    Good luck

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Random Record Within Group
    By warrenk in forum Queries
    Replies: 2
    Last Post: 10-21-2013, 02:17 PM
  2. Display random record with button
    By shredsec in forum Forms
    Replies: 3
    Last Post: 01-01-2013, 02:27 AM
  3. Replies: 1
    Last Post: 12-05-2011, 03:26 PM
  4. Random Record pull
    By Madmax in forum Access
    Replies: 2
    Last Post: 06-28-2011, 08:26 PM
  5. random record
    By wasim_sono in forum Programming
    Replies: 1
    Last Post: 02-06-2008, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums