解决方法
ANSI / ISO sql:2003介绍了窗口功能:
SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY age ASC) AS rownum,person_id,person_name,age FROM person ) AS foo WHERE rownum <= 3
Microsoft sql Server自sql Server 2005以来支持此语法.
http://msdn.microsoft.com/en-us/library/ms189798(v=sql.90).aspx
ANSI / ISO sql:2008为FETCH FIRST引入了更简单的语法,可能更类似于Microsoft / Sybase TOP语法:
SELECT person_id,age FROM person FETCH FIRST 3 ROWS ONLY
Microsoft还不支持这种语法.参见http://en.wikipedia.org/wiki/Select_(SQL)#Limiting_result_rows
如果您仍在使用Microsoft sql Server 2000,您应该阅读一段关于做“分页”风格查询的问题:
Emulate MySQL LIMIT clause in Microsoft SQL Server 2000