I am having an issue with subsequent subqueries in making a feature layer in arcpy. My table has fields: OBJECTID, pointid (long), grid_code (double)
I can successfully extract MAX(grid_code), however it returns multiple values and as such I only need the row from selection where MIN(pointid) exists.
I have not been successful in using MakeFeatureLayer and then SelectByAttribute after that as arcpy effectively concatenates the two queries with AND, where I need to select using IN (I believe).
My code as currently stands below:
arcpy.MakeFeatureLayer_management(outpoint, "centroidpoint", "grid_code IN (SELECT MAX(grid_code) FROM point WHERE (SELECT MIN (pointid) FROM point))")
outpoint is a point feature class in a geodatabase that is the result of a raster to point conversion.
Error is:
ExecuteError: ERROR 000358: Invalid expression grid_code IN (SELECT MAX(grid_code) FROM point WHERE (SELECT MAX (pointid) FROM point)) Failed to execute (MakeFeatureLayer).
I believe error is in query, however I haven't found if I can do nested / subqueries of Max/Min funcitons.
WHERE pointid = (subselect)
? Please edit your question to specify the data source, since the capabilities of the data provider impact the SQL syntax.