Using a feature service from ArcGIS Online, I would like to display a record wherein one of its attributes is the max of the entire records, but is unable to do so.

If I am using a Feature Class from a geodatabase, I would normally just specify something like this in the definition query:

enter image description here

The image above will only show records with the smallest and largest numerical value in its "admin id" field, and this works.

However when using a feature service, my challenge is identifying the table name to use. Below is the actual query being tested by me:

enter image description here

The intention of the above query is to make it show the last record edited. In lieu of the table name, ArcGIS shows a zero (0) instead. I have tried replacing the ? with 0, 1, and the layer name, but they seem to be incorrect.

enter image description here

The feature service being used was automatically created by ArcGIS Survey123, so there's no MXD for me to apply the definition query on.

Any suggestions on what I can do to do this?

  • What if you did create the query within ArcMap, publish it and created a feature service. Then in Survey123 create a new survey from that existing feature service? – Mapsy Daisy Jan 23 '18 at 12:23
  • Thanks Slinddy. Unfortunately, Survey123 automatically creates the Feature Service for us, so we are unable to modify it before being used. – NeoJigglypuff Jan 24 '18 at 23:25

Turns out that subqueries as part of the where clause is not possible in this scenario. ArcGIS Online only allows standard queries.

ArcGIS Online includes a security configuration option that forces developers to use standardized SQL queries when working with hosted feature layers. This makes it easier for developers and apps to query hosted feature layers and helps prevent SQL injection attacks. The option to allow only standard SQL queries is enabled by default.

  • same goes for windowing functions. I tried Edit_Date = Max(Edit_Date) OVER () -- just not supported in the def. query. – JasonInVegas Sep 25 '20 at 0:39

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.