<?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>idea FGDB Select By Attributes —  Expressions in subquery SELECT clause in ArcGIS Pro Ideas</title>
    <link>https://community.esri.com/t5/arcgis-pro-ideas/fgdb-select-by-attributes-expressions-in-subquery/idi-p/1375754</link>
    <description>&lt;P&gt;&lt;EM&gt;ArcGIS Pro 3.2.1; file geodatabase&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In Select by Attributes, this works:&lt;/P&gt;&lt;PRE&gt; objectid in (
    select
        &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;objectid&lt;/STRONG&gt;&lt;/FONT&gt;
    from
        species_records)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1706576286427.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/93143iE01FF42B0188D301/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_0-1706576286427.png" alt="Bud_0-1706576286427.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But this doesn't work:&lt;/P&gt;&lt;PRE&gt;objectid in (
    select
        objectid&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;+0&lt;/STRONG&gt;&lt;/FONT&gt;
    from
        species_records)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_1-1706576286428.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/93144i2A6F946D03817448/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_1-1706576286428.png" alt="Bud_1-1706576286428.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;ERROR 000358: Invalid expression&lt;/PRE&gt;&lt;P&gt;Likewise, any other SQL expression throws the same error, including expressions on text or date fields: casting a date to text, string concatenation, or changing text case using the upper() or lower() functions. Even selecting a constant/literal like 1, ‘a’, or null throws an error.&lt;/P&gt;&lt;P&gt;In other words, simply selecting a column works, but anything other than that throws an error.&amp;nbsp;I don't have that problem with mobile or enterprise geodatabases, only with file geodatabases.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Esri says it's working as designed:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Esri Case #03533443 - FGDB Select By Attributes — Subquery SELECT clause doesn't allow expressions&lt;/P&gt;&lt;P&gt;"Esri Inc has informed me that this behavior you're seeing is expected behavior. The nature of how subqueries work and the very limited nature of its implementation in FGDBs means that only those comparison operators and set functions outlined in the documentation are supported.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm#GUID-F5320DB5-4E54-4D49-BF31-A58F5379ED9F" target="_blank" rel="noopener nofollow noreferrer"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-...&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This explains why arithmetic operators, cast functions, string concatenation, and the like, fail validation in File Geodatabases. Using enterprise or mobile geodatabases is the suggested workaround."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Idea:&lt;/P&gt;&lt;P&gt;Could that behaviour be changed so that SQL expressions can be used in the SELECT clause of a subquery in Select By Attributes?&lt;/P&gt;&lt;P&gt;My example in this post is oversimplified to demonstrate the issue. My real use case is to select the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/geodatabase-questions/select-maximum-values-in-select-by-attributes/m-p/1370328/highlight/true#M8783" target="_self"&gt;greatest 1 per group&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(ties or no ties) using &lt;U&gt;Select By Attributes&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Related question:&amp;nbsp;&lt;A href="https://community.esri.com/t5/geodatabase-questions/fgdb-select-by-attributes-subquery-select-clause/m-p/1372669/highlight/true#M8815" target="_self"&gt;FGDB Select By Attributes — Subquery SELECT clause doesn't allow expressions&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2024 01:10:09 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2024-01-30T01:10:09Z</dc:date>
    <item>
      <title>FGDB Select By Attributes —  Expressions in subquery SELECT clause</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/fgdb-select-by-attributes-expressions-in-subquery/idi-p/1375754</link>
      <description>&lt;P&gt;&lt;EM&gt;ArcGIS Pro 3.2.1; file geodatabase&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In Select by Attributes, this works:&lt;/P&gt;&lt;PRE&gt; objectid in (
    select
        &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;objectid&lt;/STRONG&gt;&lt;/FONT&gt;
    from
        species_records)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1706576286427.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/93143iE01FF42B0188D301/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_0-1706576286427.png" alt="Bud_0-1706576286427.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But this doesn't work:&lt;/P&gt;&lt;PRE&gt;objectid in (
    select
        objectid&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;+0&lt;/STRONG&gt;&lt;/FONT&gt;
    from
        species_records)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_1-1706576286428.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/93144i2A6F946D03817448/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_1-1706576286428.png" alt="Bud_1-1706576286428.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;ERROR 000358: Invalid expression&lt;/PRE&gt;&lt;P&gt;Likewise, any other SQL expression throws the same error, including expressions on text or date fields: casting a date to text, string concatenation, or changing text case using the upper() or lower() functions. Even selecting a constant/literal like 1, ‘a’, or null throws an error.&lt;/P&gt;&lt;P&gt;In other words, simply selecting a column works, but anything other than that throws an error.&amp;nbsp;I don't have that problem with mobile or enterprise geodatabases, only with file geodatabases.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Esri says it's working as designed:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Esri Case #03533443 - FGDB Select By Attributes — Subquery SELECT clause doesn't allow expressions&lt;/P&gt;&lt;P&gt;"Esri Inc has informed me that this behavior you're seeing is expected behavior. The nature of how subqueries work and the very limited nature of its implementation in FGDBs means that only those comparison operators and set functions outlined in the documentation are supported.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm#GUID-F5320DB5-4E54-4D49-BF31-A58F5379ED9F" target="_blank" rel="noopener nofollow noreferrer"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-...&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This explains why arithmetic operators, cast functions, string concatenation, and the like, fail validation in File Geodatabases. Using enterprise or mobile geodatabases is the suggested workaround."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Idea:&lt;/P&gt;&lt;P&gt;Could that behaviour be changed so that SQL expressions can be used in the SELECT clause of a subquery in Select By Attributes?&lt;/P&gt;&lt;P&gt;My example in this post is oversimplified to demonstrate the issue. My real use case is to select the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/geodatabase-questions/select-maximum-values-in-select-by-attributes/m-p/1370328/highlight/true#M8783" target="_self"&gt;greatest 1 per group&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(ties or no ties) using &lt;U&gt;Select By Attributes&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Related question:&amp;nbsp;&lt;A href="https://community.esri.com/t5/geodatabase-questions/fgdb-select-by-attributes-subquery-select-clause/m-p/1372669/highlight/true#M8815" target="_self"&gt;FGDB Select By Attributes — Subquery SELECT clause doesn't allow expressions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 01:10:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/fgdb-select-by-attributes-expressions-in-subquery/idi-p/1375754</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-01-30T01:10:09Z</dc:date>
    </item>
  </channel>
</rss>

