{"id":92,"date":"2009-10-28T16:00:20","date_gmt":"2009-10-28T16:00:20","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=92"},"modified":"2010-07-22T13:34:16","modified_gmt":"2010-07-22T13:34:16","slug":"random-your-data-using-order-by-newid","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=92","title":{"rendered":"Random your data using Order by NEWID()"},"content":{"rendered":"<div class=\"snap_preview\">\n<p>This is not a new technology but I just would like to share or refresh your memory.<\/p>\n<pre>ORDER BY NEWID()<\/pre>\n<p>is used to randomly sorting query result.<\/p>\n<p>it\u2019s good if you would like to pick randomly few selected data for example : the lucky winner, the lucky customer, etc<\/p>\n<p>if you want to random all of them then the query would look like this<\/p>\n<pre>SELECT Id FROM tableName\nORDER BY NEWID()<\/pre>\n<p>but imagine if you would only take one data from 500K rows you have. It would take quite some time. them don\u2019t retrieve all of them<\/p>\n<pre>SELECT TOP N Id FROM tableName\nORDER BY NEWID()<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is not a new technology but I just would like to share or refresh your memory. ORDER BY NEWID() is used to randomly sorting query result. it\u2019s good if you would like to pick randomly few selected data for example : the lucky winner, the lucky customer, etc if you want to random all [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[112],"tags":[],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/92"}],"collection":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=92"}],"version-history":[{"count":1,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":169,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/92\/revisions\/169"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}