The python search cursor allows for using a postfix clause (i.e. group by), but it doesn't allow for using aggregate functions within the select clause. For example, there isn't any way to produce a result set that's equivalent to the following sql using an arcpy searchcursor
select some_type_field, sum(some_numeric_field) as my_sum
from xyz_table
group by some_type_field
You CAN use the group by functionality if you don't include the aggregate function in the select clause, but half the reason for grouping data is often to perform aggregation on the results, without that grouping isn't very useful. This can be worked around in very custom code situations (i.e. iterating over the result set and performing the aggregation manually), but that is super messy and not very reusable. This functionality is especially needed for accessing a file geodatabase as the alternative workaround of using a query layer (which works fine against an enterprise geodatabase) isn't an option for use against a file geodatabase. I suppose an alternative to adding the aggregation functionality to the search cursor would be to allow for query layer functionality against a file geodatabase, but I suspect that may be a bigger request to tackle 🙂
lists all the supported functions, but they are only available via. ArcObjects, not exposed via. an arcpy.da.SearchCursor.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.