I am trying to select the smallest Directionality value based on a selection of two Workingspace values:
In the above picture, there are two "Jeffery's" selected, I want to then select the Jeffery with Directionality 2 (I.E. the smaller one) without using = 2. I know there is a max/ min SQL expression:
DIRECTIONALITY = (SELECT MIN( DIRECTIONALITY) FROM TableName)
But this returns no values when choosing the select from current selection method. HOWEVER, if I create a new selection, this SQL does return a selection of 1 (it selects the row where Directionality is 1).
Is there a way to tell ArcMap to select the smallest value of a previous selection based on a different field? Specifically in Model Builder.
1 Answer 1
Your current SQL expression does not return anything from the current selection because (SELECT MIN( DIRECTIONALITY) FROM TableName)
always evaluates to 1
, which is indeed the minimum value for the whole table. You need to take the minimum value from just the rows that meet the condition WORKINGSPACE = 'Jeffery'
and you can do this in one selection instead of two. The following expression (which I am sure can be rewritten in a cleaner way) worked for me:
SELECT * FROM TableName WHERE DIRECTIONALITY = (SELECT MIN(DIRECTIONALITY) FROM TableName WHERE WORKINGSPACE = 'Jeffery')
-
Thanks so much that worked!!Sarah– Sarah2019年07月11日 14:59:07 +00:00Commented Jul 11, 2019 at 14:59
-
@Sarah Glad to help. If it solved your question, you can mark this answer as the accepted answer.Marcelo Villa– Marcelo Villa2019年07月11日 15:09:18 +00:00Commented Jul 11, 2019 at 15:09