Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有 TOP 命令。但是,如果我们不想使用 TOP 命令,那么选择前 5 个记录的最佳方法是什么?
SELECT TOP 5 * FROM table1;
一个简单但非常低效的方法:
select * from (select t.*, (select count(*) from table1 c where c.order_column <= t.order_column) top_n from table1 t) sq where top_n <= 5