Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's not standard SQL. This was standardized pretty late, so different RDBMS have various syntaxes, but the standardized one is to add a clause like this:

    FETCH FIRST n ROWS ONLY
In PostgreSQL and MySQL the usual syntax is a LIMIT clause, but PostgreSQL also supports the standard. MSSQL and some others use TOP n directly after SELECT. I think in some others you need to use a window function.


Top n is even deprecated in mssql, in favor of top(n).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: