@SethuSrinivasan , 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.
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.
Three patterns worth knowing:
Just the first N rows in any order: SELECT * FROM table1 LIMIT 10;
Top N by a column — say, highest salary: SELECT * FROM employees ORDER BY salary DESC LIMIT 10;
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 <= 3;
That last one is more flexible than TOP ever was anyway, and it scales well once you start dealing with more complex ranking logic.
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.
Hope this helps, Louis.