Oracle SELECT TOP 10 records

You’ll need to put your current query in subquery as below : Oracle applies rownum to the result after it has been returned.You need to filter the result after it has been returned, so a subquery is required. You can also use RANK() function to get Top-N results. For performance try using NOT EXISTS in place of NOT IN. See this for more.