{"id":6415,"date":"2017-04-18T08:53:56","date_gmt":"2017-04-18T08:53:56","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=6415"},"modified":"2017-04-20T11:19:23","modified_gmt":"2017-04-20T11:19:23","slug":"how-to-select-n-random-records-from-a-db2-table","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/tips\/how-to-select-n-random-records-from-a-db2-table.html","title":{"rendered":"How to select N random records from a DB2 table"},"content":{"rendered":"<p>If you want to select N random records from a DB2 table, you need to change the clause as follows:<\/p>\n<p><strong>select * from tableName order by rand() fetch first N rows only<\/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 * from customers order by rand() fetch first 5 rows only<\/strong><\/p>\n<p>Some DB2 tools you can try: <a href=\"https:\/\/www.withdata.com\/db2\/\"> https:\/\/www.withdata.com\/db2\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to select N random records from a DB2 table, you need to change the clause as follows: select * from tableName order by rand() fetch first N rows only For example, to select 5 random customers in the customers table, you use the following query: select * from customers order by rand() [&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":[1318,1964],"class_list":["post-6415","post","type-post","status-publish","format-standard","hentry","category-tips","tag-db2","tag-random-records"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6415","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=6415"}],"version-history":[{"count":3,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6415\/revisions"}],"predecessor-version":[{"id":6483,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6415\/revisions\/6483"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=6415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=6415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=6415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}