<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Requesting support for &amp;quot;SELECT TOP n from Table&amp;quot; in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/requesting-support-for-quot-select-top-n-from-table-quot/m-p/150955#M53546</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/20462"&gt;@SethuSrinivasan&lt;/a&gt;&amp;nbsp;, Looks like this one slipped through the cracks — apologies if you've long since moved on, but posting anyway in case it helps someone hitting the same wall.&lt;/P&gt;
&lt;P&gt;In Databricks SQL, SELECT TOP n doesn't exist. You get the same result with LIMIT, and if you care about which rows you're getting, pair it with ORDER BY.&lt;/P&gt;
&lt;P&gt;Three patterns worth knowing:&lt;/P&gt;
&lt;P&gt;Just the first N rows in any order: SELECT * FROM table1 LIMIT 10;&lt;/P&gt;
&lt;P&gt;Top N by a column — say, highest salary: SELECT * FROM employees ORDER BY salary DESC LIMIT 10;&lt;/P&gt;
&lt;P&gt;Top N per group — say, top 3 orders per customer — you'll want a window function: SELECT * FROM (SELECT o.*, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_total DESC) AS rn FROM orders o) WHERE rn &amp;lt;= 3;&lt;/P&gt;
&lt;P&gt;That last one is more flexible than TOP ever was anyway, and it scales well once you start dealing with more complex ranking logic.&lt;/P&gt;
&lt;P&gt;Rule of thumb: wherever you'd write SELECT TOP 10 * FROM table1 in SQL Server, swap it for LIMIT 10 in Databricks SQL. Tack on ORDER BY if the order actually matters to you.&lt;/P&gt;
&lt;P&gt;Hope this helps, Louis.&lt;/P&gt;</description>
    <pubDate>Sat, 14 Mar 2026 20:13:02 GMT</pubDate>
    <dc:creator>Louis_Frolio</dc:creator>
    <dc:date>2026-03-14T20:13:02Z</dc:date>
    <item>
      <title>Requesting support for "SELECT TOP n from Table"</title>
      <link>https://community.databricks.com/t5/data-engineering/requesting-support-for-quot-select-top-n-from-table-quot/m-p/29008#M20765</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In notebook, It looks like if I need to select top N rows, I can rely on "LIMIT" keyword. It would be nice if you can support "TOP" as well&lt;/P&gt;
&lt;P&gt;&lt;B&gt;The current approach to select 10 rows:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;select * from table1 LIMIT 10&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Requesting TOP support:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;SELECT TOP 10 * from table1&lt;/P&gt;
&lt;P&gt;It is quite common for SQL Server users to use TOP clause in their queries. Can you please add this support to your SQL language?&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Nov 2017 19:32:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/requesting-support-for-quot-select-top-n-from-table-quot/m-p/29008#M20765</guid>
      <dc:creator>SethuSrinivasan</dc:creator>
      <dc:date>2017-11-25T19:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Requesting support for "SELECT TOP n from Table"</title>
      <link>https://community.databricks.com/t5/data-engineering/requesting-support-for-quot-select-top-n-from-table-quot/m-p/150955#M53546</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/20462"&gt;@SethuSrinivasan&lt;/a&gt;&amp;nbsp;, Looks like this one slipped through the cracks — apologies if you've long since moved on, but posting anyway in case it helps someone hitting the same wall.&lt;/P&gt;
&lt;P&gt;In Databricks SQL, SELECT TOP n doesn't exist. You get the same result with LIMIT, and if you care about which rows you're getting, pair it with ORDER BY.&lt;/P&gt;
&lt;P&gt;Three patterns worth knowing:&lt;/P&gt;
&lt;P&gt;Just the first N rows in any order: SELECT * FROM table1 LIMIT 10;&lt;/P&gt;
&lt;P&gt;Top N by a column — say, highest salary: SELECT * FROM employees ORDER BY salary DESC LIMIT 10;&lt;/P&gt;
&lt;P&gt;Top N per group — say, top 3 orders per customer — you'll want a window function: SELECT * FROM (SELECT o.*, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_total DESC) AS rn FROM orders o) WHERE rn &amp;lt;= 3;&lt;/P&gt;
&lt;P&gt;That last one is more flexible than TOP ever was anyway, and it scales well once you start dealing with more complex ranking logic.&lt;/P&gt;
&lt;P&gt;Rule of thumb: wherever you'd write SELECT TOP 10 * FROM table1 in SQL Server, swap it for LIMIT 10 in Databricks SQL. Tack on ORDER BY if the order actually matters to you.&lt;/P&gt;
&lt;P&gt;Hope this helps, Louis.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2026 20:13:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/requesting-support-for-quot-select-top-n-from-table-quot/m-p/150955#M53546</guid>
      <dc:creator>Louis_Frolio</dc:creator>
      <dc:date>2026-03-14T20:13:02Z</dc:date>
    </item>
  </channel>
</rss>

