Basically I'm trying to create a selection that satisfies a random criteria AND a query based on an attribute field. Here is some sample code I found on StackExchange:
def SelectRandomByCount (layer, count):
import random
layerCount = int (arcpy.GetCount_management (layer).getOutput (0))
if layerCount < count:
print "input count is greater than layer count"
return
oids = [oid for oid, in arcpy.da.SearchCursor (layer, "OID@")]
oidFldName = arcpy.Describe (layer).OIDFieldName
delimOidFld = arcpy.AddFieldDelimiters (layer, oidFldName)
randOids = random.sample (oids, count)
oidsStr = ", ".join (map (str, randOids))
sql = "{0} IN ({1})".format (delimOidFld, oidsStr)
arcpy.SelectLayerByAttribute_management (layer, "", sql)
What I need is this in conjunction with a query (from the same input later) where FIELD = Value (for a string field).
I have reviewed the ESRI help document related to Specifying a query in Python, but am having difficulty understanding how to implement this.