This blog is subject the DISCLAIMER below.

Thursday, July 10, 2008

Top 10 syntax (Oracle and SQL)

As my experience in Microsoft development, I was think that the syntax for retrieving top 10 records in SQL server is same with Oracle but unfortunately they were different so here the syntax of both :

SQL SERVER :

SELECT TOP 10 age FROM Employees

ORACLE :

SELECT age FROM Employees WHERE ROWNUM <= 10

1 comment:

Anonymous said...

Oracle statement should not work, because Oracle returns data in random order. You have to order the data in a subquery before getting the top N rows.