arcpy SearchCursor, SQL statement invalid

icecold

New Member
I'm trying to select the max(and min in a separate code block, not shown) of values from 3 columns. I'm trying to model my code after some working code I saw with a search cursor. I need to be able to access whatever the max value is later to write to a file.The problem is my SQL expression in the search cursor. I've tried about 5 variations that I can think of but none of them will run. I don't know a lot about SQL expressions, but I can usually at least get them right in the ArcMap GUI. In a python script its like finding a snake in the dark.Here's my code:\[code\] #input shapefileinputFC = 'C:whatever.shp'#variable to define the field namesfields = ['Crude_R1', 'Crude_R2', 'Crude_R3', 'STATE_NAME', 'Age_Adj_R1', 'Age_Adj_R2', 'Age_Adj_R3']CRmax = 0cursor = arcpy.da.SearchCursor(inputFC, fields[0:2], 'MAX "Crude_R1" AND "Crude_R2" AND "Crude_R3"')for row in cursor: print row[0:2]CRmax = row[0:2]del rowdel cursor\[/code\]Error msg:\[code\]Traceback (most recent call last):File "C:\whatever.py", line 64, in <module>for row in cursor:RuntimeError: An invalid SQL statement was used.\[/code\]
 
Top