<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS Pro: how to QUERY a text field with a numeric operator in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179101#M7963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly I want to point out, your original function&amp;nbsp;threw an error because you are trying to compare integer to a string. This can be avoided in your case by using the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;Tot_Value &amp;gt;= '500000'‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this may not be what you want either.&amp;nbsp;The comparison checks each letter of the string one at a time until it finds a difference. However, this can cause problems if your values in that field are of varying length. See screenshot below to see what happens when comparing different length strings.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="418257" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/418257_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you would like this solution to work, one possibly remedy is to ensure that all the values in your text field are the same length. However, if this is not possible we will need an alternate solution. We can make use of the string comparisons by using the SQL's LEFT and RIGHT operators. This allows us to extract the right-most side of the string for comparison. For example RIGHT('102', 2) will return '02'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How is this useful?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If we want to make sure a number is greater than 5, we can use RIGHT(Tot_Value, 1) &amp;gt; '5'. However, notice that a value of '12' will return False as it will compare '1' &amp;gt; '5' first. Therefore, to remedy this we can filter out entries&amp;nbsp;that are always larger by checking the string length, and then, only when an item is the same length as the search number, we check the value. Thus we can apply the following where clause:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="line-numbers language-sql"&gt;&lt;CODE&gt;LENGTH&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Value&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;‍ &lt;SPAN class="operator token"&gt;OR&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;RIGHT&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Value&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'5'&lt;/SPAN&gt;‍‍‍‍‍‍‍‍ &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; LENGTH&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Value&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;‍&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This will ensure that only numbers larger than '5' are obtained. Once the string hits the length threshold, that the minimum value (RIGHT) is always greater than '5'. To apply this for&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;500000 we would do this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now, this query may depend on your DBMS. For example, ORACLE does not have a RIGHT function, and thus I need to use SUBSTR instead. Make note of your DBMS and what type of string functions are available. That being said, this type of query should be possible in all SQL variants. That being said, let's apply this to your case of 500000:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;To compare if a string is larger than a number:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="line-numbers language-sql"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;LEN&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;OR&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;RIGHT&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'500000'&lt;/SPAN&gt;‍‍‍‍‍‍ &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;LEN&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For oracle:&lt;/P&gt;&lt;PRE class="line-numbers language-sql"&gt;&lt;CODE&gt;LENGTH&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;OR&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;SUBSTR&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'500000'&lt;/SPAN&gt;‍‍‍‍‍‍‍ &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; LENGTH&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To compare if a string is smaller than a number:&lt;/P&gt;&lt;PRE class="line-numbers language-sql"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;LEN&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;OR&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;RIGHT&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'500000'&lt;/SPAN&gt;‍‍‍‍‍ &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;LEN&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Oracle:&lt;/P&gt;&lt;PRE class="line-numbers language-sql"&gt;&lt;CODE&gt;LENGTH&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;OR&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;SUBSTR&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'500000'&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍ &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; LENGTH&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Tot_Length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know this isn't very elegant, however it does work. I hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Aug 2018 15:38:32 GMT</pubDate>
    <dc:creator>QuinnBast</dc:creator>
    <dc:date>2018-08-07T15:38:32Z</dc:date>
    <item>
      <title>ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179076#M7938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using an AGOL based feature layer that has all its features stored as text.&amp;nbsp; I want to use a query such as "Tot_Value &amp;gt;= 500000", however I get an error since Tot_Value is a text string.&amp;nbsp; I recall an earlier version of ArcMap allowed this type of operation using the same data source, so I believe it can be done.&amp;nbsp; I'm not a SQL expert, but assume I can cast this to an Int or similar, however a web search is coming up dry, and attempts on my part generate errors.&amp;nbsp; Suggestions?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 13:59:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179076#M7938</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T13:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179077#M7939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,'helvetica neue',verdana,sans-serif;"&gt;'&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;int("Tot_Value") &amp;gt;= 500000'&amp;nbsp; would be too easy I suppose (or some variant)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="-webkit-text-stroke-width: 0px; word-wrap: break-word; color: #3d3d3d; white-space: normal; font-weight: 400; display: inline !important; letter-spacing: normal; text-decoration: none; font-size: 15px; font-style: normal; float: none; background-color: transparent; text-transform: none; word-spacing: 0px; font-variant: normal; text-indent: 0px; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; orphans: 2; text-align: left;"&gt;But you don't get the option in the sql builder, So I suspect adding a new field and doing the conversion and test in a def is your best option&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 14:08:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179077#M7939</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-06T14:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179078#M7940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep... just gets an syntax error....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 14:15:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179078#M7940</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T14:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179079#M7941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;func&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;val&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; threshold&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"""convert and compare"""&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; val &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; val
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;val&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; threshold&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; out


&lt;SPAN class="comment token"&gt;# expression&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# func(!YourTextField!, 50000)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;make a new field and figure out what you want to do when the threshold is exceeded as in the example above&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179079#M7941</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T09:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179080#M7942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What if your system is locked down and schema changes such as this require extensive testing to downstream apps?&amp;nbsp; This seems like functionality that should be built into the software and not require the addition of almost a duplicate field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 14:36:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179080#M7942</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2018-08-06T14:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179081#M7943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can CAST in SQL:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;CAST(SomeField&amp;nbsp;AS INT) &amp;gt;= 500000&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 14:55:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179081#M7943</guid>
      <dc:creator>PeteCrosier</dc:creator>
      <dc:date>2018-08-06T14:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179082#M7944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One would think so but I still get an error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/418122_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Curiously, if I drop the WHERE, I get a different error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/418123_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In both cases the fact that 500000 is in red is a flag. &amp;nbsp;I've tried smaller numbers, decimal points, etc. without success.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 15:09:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179082#M7944</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T15:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179083#M7945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, but it needs to be viable in the ArcGIS Pro Select by Attribute SQL Expression Window.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 15:10:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179083#M7945</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T15:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179084#M7946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Cast statement does not appear to be helpful as the OP still gets an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chuck:&lt;/P&gt;&lt;P&gt;Have you tried working with ESRI technical support on this issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 15:14:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179084#M7946</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2018-08-06T15:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179085#M7947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do more with ArcPy than what the GUI will let you.&amp;nbsp; Since the ArcGIS relational data store is backed by PostgreSQL, try the following in the Python window:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CAST (Tot_Value as INTEGER) &amp;gt; 500000"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 15:29:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179085#M7947</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-08-06T15:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179086#M7948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Josh, &amp;nbsp;Thanks. &amp;nbsp;I've tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("PAAG_-_Feature_Layer\PAAG_-_Feature_Layer", "NEW_SELECTION", "WHERE CAST (TOT_VALUE as INTEGER) &amp;gt; 500000"")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parsing error &lt;BR /&gt;SyntaxError: EOL while scanning string literal (&amp;lt;string&amp;gt;, line 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I started with the layer not in quotes (which is how I think it should be)... same error.&lt;/P&gt;&lt;P&gt;Suggestion as to what I'm doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 15:53:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179086#M7948</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T15:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179087#M7949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Progress: I needed to refer to TOT_VALUE inside quotes. &amp;nbsp;But now it says the expression is invalid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("PAAG_-_Feature_Layer\PAAG_-_Feature_Layer", "NEW_SELECTION", 'WHERE CAST ("TOT_VALUE" AS INTEGER) &amp;gt; 500000')&lt;BR /&gt;Runtime error &lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 6314, in SelectLayerByAttribute&lt;BR /&gt; raise e&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 6311, in SelectLayerByAttribute&lt;BR /&gt; retval = convertArcObjectToPythonObject(gp.SelectLayerByAttribute_management(*gp_fixargs((in_layer_or_view, selection_type, where_clause, invert_where_clause), True)))&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in &amp;lt;lambda&amp;gt;&lt;BR /&gt; return lambda *args: val(*gp_fixargs(args, True))&lt;BR /&gt;arcgisscripting.ExecuteError: ERROR 000358: Invalid expression&lt;BR /&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought that maybe the "WHERE" was not needed, tried it without that, same result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:14:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179087#M7949</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T16:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179088#M7950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why was the field a text field in the first place?&lt;/P&gt;&lt;P&gt;Are there other non-numeric values in there?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:30:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179088#M7950</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-06T16:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179089#M7951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its a text field, as are all the user defined fields in this layer. &amp;nbsp;Thats how the content provider has formatted this data for years.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:36:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179089#M7951</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T16:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179090#M7952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have an extra quotes in the ArcPy code you pasted, which would generate the error you see.&amp;nbsp; Trying copying and pasting this:&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("PAAG_-_Feature_Layer\PAAG_-_Feature_Layer", "NEW_SELECTION", "WHERE CAST (TOT_VALUE as INTEGER) &amp;gt; 500000")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:39:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179090#M7952</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-08-06T16:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179091#M7953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again. &amp;nbsp;I have a new error now, see below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("PAAG_-_Feature_Layer\PAAG_-_Feature_Layer", "NEW_SELECTION", "WHERE CAST (TOT_VALUE as INTEGER) &amp;gt; 500000")&lt;BR /&gt;Runtime error &lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 6314, in SelectLayerByAttribute&lt;BR /&gt; raise e&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 6311, in SelectLayerByAttribute&lt;BR /&gt; retval = convertArcObjectToPythonObject(gp.SelectLayerByAttribute_management(*gp_fixargs((in_layer_or_view, selection_type, where_clause, invert_where_clause), True)))&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in &amp;lt;lambda&amp;gt;&lt;BR /&gt; return lambda *args: val(*gp_fixargs(args, True))&lt;BR /&gt;arcgisscripting.ExecuteError: ERROR 000358: Invalid expression&lt;BR /&gt;ERROR: code:504, Your request has timed out., Proxy server got bad address from remote server (verify the server is running).&lt;BR /&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While I still have an "Invalid Expression" error, I also now have a time out. &amp;nbsp;I think this may be because I'm querying a huge (100+M records) layer. &amp;nbsp;I'm also trying to figure out how to limit my query to only the visible extent of the map. &amp;nbsp;I started another request here:&amp;nbsp;&lt;A href="https://community.esri.com/message/790143-arcgis-pro-how-to-limit-select-by-attribute-to-the-visible-extent"&gt;https://community.esri.com/message/790143-arcgis-pro-how-to-limit-select-by-attribute-to-the-visible-extent&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:57:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179091#M7953</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T16:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179092#M7954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about applying a definition query to the layer to limit it to just 10,000 or 100,000 records just to see if the time out error goes away?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 17:03:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179092#M7954</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2018-08-06T17:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179093#M7955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the other thread it was suggested I use "Select from Current Selection", which makes sense. &amp;nbsp;In this case, I've substituted "SUBSET_SELECTION" for "NEW_SELECTION", and made a rectangular selection of a small area before running the script. &amp;nbsp;Same sort of delay, but I didn't see the Code 504 error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 17:23:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179093#M7955</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2018-08-06T17:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179094#M7956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Casting a field will not allow the index to be used, if there is one, so you are basically doing a full-table scan on 100+M records.&amp;nbsp; It isn't surprising it is timing out.&amp;nbsp; Getting back to what Dan has mentioned, you really need to convert the field to integer and then index it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 17:26:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179094#M7956</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-08-06T17:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro: how to QUERY a text field with a numeric operator</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179095#M7957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The OP says that this operation used to work in ArcMap.&amp;nbsp; Does this not appear to be a step backwards using Pro if you now need to create near duplicate fields that were not necessary in the past due to performance issues in Pro?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2018 17:30:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-how-to-query-a-text-field-with-a/m-p/179095#M7957</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2018-08-06T17:30:24Z</dc:date>
    </item>
  </channel>
</rss>

