Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Location
    UK
    Posts
    40

    Unanswered: Randomise recordset

    Hello,

    I was wondering if there is a way to randomise a recordset once you have performed a query.
    eg I want my query return a set of records based upon criteria supplied and then either randomise the order of the recordset or only return 3 random records - which every is simplest to do.

    Can this be done in SQL or do I need to handle it outside of my SQL query in my business logic?

    Many Thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select top 3 foo,bar from yourtable where qux=937 order by newid()
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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