Select statement with random order by

Posted on 2011-10-24
Last Modified: 2012-05-12
I have a select statement

I want to do an order by with a random sort on the rownumber returned.
Question by:lrbrister
    LVL 59

    Accepted Solution

    For SQL Server, you have the RAND() or NEWID() functions that can be used to generate random ordering.

    e.g., ORDER BY NEWID()
    LVL 59

    Expert Comment

    by:Kevin Cross
    Some folks even combine the two like so to get more truly random sequence by seeding RAND().



    Author Closing Comment

    Perfect.  Thanks

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now