<?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: How to use SQL aggregate functions in a definition query ? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-sql-aggregate-functions-in-a-definition/m-p/227632#M9896</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data is in a file geodatabase, your approach won't work.&amp;nbsp; First off, your SQL is invalid in several DBMSs, not just file geodatabases.&amp;nbsp; What you would need to do, instead of using SQL IN, is use a correlated subquery using SQL EXISTS.&amp;nbsp; Unfortunately, file geodatabases don't properly support correlated subqueries with EXISTS, so you are out of luck going down the definition query path.&amp;nbsp; See &lt;A href="https://community.esri.com/thread/169714"&gt;https://community.esri.com/thread/169714&lt;/A&gt; for more discussion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Sep 2019 22:55:25 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-09-10T22:55:25Z</dc:date>
    <item>
      <title>How to use SQL aggregate functions in a definition query ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-sql-aggregate-functions-in-a-definition/m-p/227631#M9895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a feature class of point data in a file geodatabase. The points include a location_id, date, and a chemical_result. Because there is more than one result, the points are displayed in duplicate. I do not want to use a related table in this instance - I just want one point to display the maximum result, and the date of each max result result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I would be able to write a definition query as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOCATION_ID IN (SELECT LOCATION_ID, DATE, MAX(CHEMICAL_RESULT) FROM layer_name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GROUP BY LOCATION_ID);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT x.DATE, x.LOCATION_ID, y.max_result &lt;BR /&gt;FROM&amp;nbsp;layer_name x &lt;BR /&gt;INNER JOIN (SELECT LOCATION_ID, MAX(CHEMICAL_RESULT) max_result&lt;BR /&gt;FROM layer_name&lt;BR /&gt;GROUP BY LOCATION_ID&lt;BR /&gt;) y ON x.LOCATION_ID = y.LOCATION_ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I receive an invalid SQL error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I get the max result, the location ID, and the date of the max result?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 18:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-sql-aggregate-functions-in-a-definition/m-p/227631#M9895</guid>
      <dc:creator>JasonCarter1</dc:creator>
      <dc:date>2019-09-10T18:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SQL aggregate functions in a definition query ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-sql-aggregate-functions-in-a-definition/m-p/227632#M9896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data is in a file geodatabase, your approach won't work.&amp;nbsp; First off, your SQL is invalid in several DBMSs, not just file geodatabases.&amp;nbsp; What you would need to do, instead of using SQL IN, is use a correlated subquery using SQL EXISTS.&amp;nbsp; Unfortunately, file geodatabases don't properly support correlated subqueries with EXISTS, so you are out of luck going down the definition query path.&amp;nbsp; See &lt;A href="https://community.esri.com/thread/169714"&gt;https://community.esri.com/thread/169714&lt;/A&gt; for more discussion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 22:55:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-sql-aggregate-functions-in-a-definition/m-p/227632#M9896</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-09-10T22:55:25Z</dc:date>
    </item>
  </channel>
</rss>

