Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to use a SELECT TOP (n) within ArcGIS desktop? Is appears that since the ArcGIS query builder is effectively building the SQL statement after the WHERE clause, that this may not be possible.

Here is a typical SQL example of usage:


share|improve this question
Note that TOP and LIMIT are not supported in file geodatabases: – blah238 Jan 15 '13 at 7:34
up vote 9 down vote accepted

If your underlying database supports sub queries, you can build a query with a TOP N that returns ObjectIds (or any other field) and use that in your definition query.

OBJECTID IN (*query here*)

For example, here's a SQL Server query for a TOP 20, random selection: enter image description here

The above query will return 20 different rows each time the map or attribute table is refreshed. This also could come in handy for an ArcMap practical joke for less experienced users (April Fools is less than a month away).

Of course, the sub query doesn't have to be a TOP N query nor do you need to use a unique id. Maybe work up a query to find duplicates:


share|improve this answer
nice! I can see this giving a loot of trouble to some users.."what did you do to the database???" – George Mar 6 '11 at 13:53
While I was really hoping I could do this with shapefiles, it appears I cannot. However, this appears to be a very good way of solving the issue when calling data from a SQL data source that supports SELECT TOP queries. Thanks. – RyanDalton Mar 9 '11 at 17:04
You can use such queries within the Definition query, but is there any workaround to use them within Select by Attribute tool? It already has this SELECT FROM part pre-populated. – Alex Tereshenkov Feb 20 '14 at 7:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.