{"id":288,"date":"2011-03-16T13:29:47","date_gmt":"2011-03-16T18:29:47","guid":{"rendered":"http:\/\/www.cfchimp.com\/wordpress\/?p=288"},"modified":"2024-12-05T19:47:36","modified_gmt":"2024-12-06T00:47:36","slug":"oracle-equivalent-of-sql-server-select-top-select-top-n","status":"publish","type":"post","link":"https:\/\/csimmons.dev\/blog\/2011\/03\/oracle-equivalent-of-sql-server-select-top-select-top-n\/","title":{"rendered":"Oracle equivalent of SQL Server SELECT TOP (SELECT TOP n)"},"content":{"rendered":"<p>I had to do a small update on a site for work with an Oracle back end.\u00a0 I don&#8217;t work with Oracle so I ran into a little snag.\u00a0 I needed to find the Oracle equivalent of SQL Server&#8217;s &#8220;SELECT TOP&#8221;.\u00a0 So, here it is:<\/p>\n<p><strong>MS SQL<\/strong><br \/>\n<code><br \/>\nSELECT TOP 10<br \/>\nfield1, field2<br \/>\nFROM<br \/>\ntablename<br \/>\nORDER BY<br \/>\nfield1<br \/>\n<\/code><\/p>\n<p><strong>ORACLE<\/strong><br \/>\n<code><br \/>\nSELECT *<br \/>\nFROM<br \/>\n(SELECT<br \/>\nfield1, field2<br \/>\nFROM<br \/>\ntablename<br \/>\nORDER BY field1)<br \/>\nWHERE<br \/>\nROWNUM &lt;= 10<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had to do a small update on a site for work with an Oracle back end.\u00a0 I don&#8217;t work with Oracle so I ran into a little snag.\u00a0 I needed to find the Oracle equivalent of SQL Server&#8217;s &#8220;SELECT TOP&#8221;.\u00a0 So, here it is: MS SQL SELECT TOP 10 field1, field2 FROM tablename ORDER &#8230; <a title=\"Oracle equivalent of SQL Server SELECT TOP (SELECT TOP n)\" class=\"read-more\" href=\"https:\/\/csimmons.dev\/blog\/2011\/03\/oracle-equivalent-of-sql-server-select-top-select-top-n\/\" aria-label=\"Read more about Oracle equivalent of SQL Server SELECT TOP (SELECT TOP n)\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_cloudinary_featured_overwrite":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[68],"tags":[29,16],"class_list":["post-288","post","type-post","status-publish","format-standard","hentry","category-developer","tag-oracle","tag-sql"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pbVg43-4E","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/comments?post=288"}],"version-history":[{"count":0,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions"}],"wp:attachment":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/media?parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/tags?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}