{"id":6404,"date":"2017-04-18T08:38:56","date_gmt":"2017-04-18T08:38:56","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=6404"},"modified":"2017-04-20T11:22:29","modified_gmt":"2017-04-20T11:22:29","slug":"how-to-select-n-random-records-from-an-oracle-table","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/tips\/how-to-select-n-random-records-from-an-oracle-table.html","title":{"rendered":"How to select N random records from an Oracle table"},"content":{"rendered":"<p>If you want to select N random records from an Oracle table, you need to change the clause as follows:<\/p>\n<p><strong>select\u00a0*\u00a0from<\/strong><br \/>\n<strong> (<\/strong><br \/>\n<strong> select*\u00a0\u00a0from\u00a0tableName\u00a0\u00a0order\u00a0by\u00a0dbms_random.value<\/strong><br \/>\n<strong> )<\/strong><br \/>\n<strong> where\u00a0rownum\u00a0&lt;= N;<\/strong><\/p>\n<p>For example, to select 5 random customers in the customers table, you use the following query:<\/p>\n<p><strong>select\u00a0*\u00a0from<\/strong><br \/>\n<strong> (<\/strong><br \/>\n<strong> select*\u00a0\u00a0from customers order\u00a0by\u00a0dbms_random.value<\/strong><br \/>\n<strong> )<\/strong><br \/>\n<strong> where\u00a0rownum\u00a0&lt;= 5;<\/strong><\/p>\n<p>Some Oracle tools you can try: <a href=\"https:\/\/www.withdata.com\/oracle\/\"> https:\/\/www.withdata.com\/oracle\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to select N random records from an Oracle table, you need to change the clause as follows: select\u00a0*\u00a0from ( select*\u00a0\u00a0from\u00a0tableName\u00a0\u00a0order\u00a0by\u00a0dbms_random.value ) where\u00a0rownum\u00a0&lt;= N; For example, to select 5 random customers in the customers table, you use the following query: select\u00a0*\u00a0from ( select*\u00a0\u00a0from customers order\u00a0by\u00a0dbms_random.value ) where\u00a0rownum\u00a0&lt;= 5; Some Oracle tools you can [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[1325,1964],"class_list":["post-6404","post","type-post","status-publish","format-standard","hentry","category-tips","tag-oracle","tag-random-records"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=6404"}],"version-history":[{"count":5,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6404\/revisions"}],"predecessor-version":[{"id":6489,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6404\/revisions\/6489"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=6404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=6404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=6404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}