I want to get the maximum OBJECTID from a layer using "select by attribute" tool. But the result is not with the maximum OBJECTID.

When I use "select by attribute" tool to get the maximum last_edited_date, I also cannot get the latest date value.

The feature with the maximum OBJECTID and last_edited_date is newly created.

The sql statement used in the :select by attribute" is as follows:

enter image description here

The result of the selection: enter image description here

The reason of getting the maximum OBJECTID and last_edited_date is I want to set the attribute value for the feature and after that create a buffer around the newly created feature.

I am using arcmap 10.2.

  • could there be different schemas that have the same table BQ_Segment_1 within scope? What happens if you fully qualify the table in the FROM clause? – ako Sep 17 '14 at 4:45
  • 2
    Is it possible that the MAX object ID isn't in the table but in a delta table instead, the max returned being the highest OBJECTID at the last compress? ArcMap sees the base table modified by the delta tables but the database only sees the base table. – Michael Stimson Sep 17 '14 at 4:46

As an alternative to using the Select By Attributes tool alone, I recommend writing a short Python/ArcPy script tool which uses:

  1. Summary Statistics to get the MAXIMUM value of OBJECTID
  2. arcpy.da.SearchCursor to read the value of the MAX-OBJECTID field in the first (and only) row of the table that results from 1.
  3. Select By Attributes to select the feature with that maximum value of OBJECTID that results from 2..
| improve this answer | |
  • 1
    You could also use a MAX(objectid) on the versioned view, to get the maximum in one version, but there's no guarantee that the maximum in that version is the maximum of all versions. – Vince Sep 17 '14 at 5:39
  • @ppLily If your question involves Geodatabase Versioning that would be something to include in it as a highly relevant detail. – PolyGeo Sep 17 '14 at 5:52
  • Hi Vince and PolyGeo, it seems I must consider the geodatabase versioning. – ppLily Sep 17 '14 at 6:21
  • @ppLily The Help has a very useful page on How to frame a good question? which is well worth a read or refresh of, in order to keep attracting potential answerers to your questions. – PolyGeo Sep 17 '14 at 7:01
  • Hi PolyGeo, I am so sorry for the misleading of the question, I am also not realize the versioning issue. I will be careful next time, thanks for your patient. – ppLily Sep 17 '14 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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