Pulling 10 Random rows

Results 1 to 2 of 2

Thread: Pulling 10 Random rows

  1. #1
    Join Date
    Dec 1969

    Default Pulling 10 Random rows

    How can I pull 10 rows randomly from a database? Is there an SQL statement for this?<BR><BR>Thanks,<BR>

  2. #2
    Nathan Pond Guest

    Default RE: Pulling 10 Random rows

    This is an interesting question. I remember having a heck of a time getting one random value returned to me this past summer. I finally got it though. I&#039m not sure if this is the most efficient way of doing it, but in your case I would probably write a stored procedure to select one random row at a time and store it into a temp table. When 10 random rows have been retrieved just select * from temptable and you&#039re in business.<BR><BR>I have a stored procedure already that will return one random row, let me know if you&#039d like me to e-mail it to you. The only problem I can see with my solution is that you may get the same row more than once, but there are ways to code around that too.<BR><BR>Let me know if there is anything else I can do to help you out.<BR><BR>Nathan Pond

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts