<?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 Make Query Table — Use date field in join in ArcGIS Pro Ideas</title>
    <link>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idi-p/1369341</link>
    <description>&lt;P&gt;&lt;EM&gt;ArcGIS Pro 3.2.1; file geodatabase&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It's my understanding that date fields can't be used in joins between tables/FCs in the Make Query Table tool. The Key Field Options parameter excludes date fields from the pick list.&lt;/P&gt;&lt;P&gt;Could that be changed so that date fields are supported in joins? For example, join on SPECIES=SPECIES and DATE=DATE.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1705022604583.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91346i4010EA0D2D06F87F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_0-1705022604583.png" alt="Bud_0-1705022604583.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Related:&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/joins-based-on-multiple-fields/idc-p/947158/highlight/true#M6495" target="_self"&gt;Joins based on multiple fields&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/selecting-the-most-recent-records-based-on-unique/td-p/1365493" target="_self"&gt;Selecting the most recent records based on unique values in another field&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Sat, 13 Jan 2024 18:56:51 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2024-01-13T18:56:51Z</dc:date>
    <item>
      <title>Make Query Table — Use date field in join</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idi-p/1369341</link>
      <description>&lt;P&gt;&lt;EM&gt;ArcGIS Pro 3.2.1; file geodatabase&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It's my understanding that date fields can't be used in joins between tables/FCs in the Make Query Table tool. The Key Field Options parameter excludes date fields from the pick list.&lt;/P&gt;&lt;P&gt;Could that be changed so that date fields are supported in joins? For example, join on SPECIES=SPECIES and DATE=DATE.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1705022604583.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91346i4010EA0D2D06F87F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_0-1705022604583.png" alt="Bud_0-1705022604583.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Related:&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/joins-based-on-multiple-fields/idc-p/947158/highlight/true#M6495" target="_self"&gt;Joins based on multiple fields&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/selecting-the-most-recent-records-based-on-unique/td-p/1365493" target="_self"&gt;Selecting the most recent records based on unique values in another field&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Sat, 13 Jan 2024 18:56:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idi-p/1369341</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-01-13T18:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Make Query Table — Use date field in join - Status changed to: Needs Clarification</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idc-p/1369350#M27987</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/351335"&gt;@Bud&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;did you happen to try Create Database View and see if that work? I did a quick test with some made up datasets and it worked for me (fingers crossed).&lt;/P&gt;&lt;P&gt;as you know this tool allows you to use sql statements to create a view inside a file gdb.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TanuHoque_1-1705024245162.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91350iE6BD6711E84A6F6B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TanuHoque_1-1705024245162.png" alt="TanuHoque_1-1705024245162.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 01:51:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idc-p/1369350#M27987</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2024-01-12T01:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Make Query Table — Use date field in join</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idc-p/1369460#M27992</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2620"&gt;@TanuHoque&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been having trouble with FGDB views. So I was hoping to use Make Query Table as an alternative.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;STRONG&gt;Details:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sample Excel data is attached to the original post above. It can be loaded into a file geodatabase.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I came across this issue with a FGDB view:&lt;/P&gt;&lt;PRE&gt;--latest_vw &lt;FONT color="#999999"&gt;(I don't include these comments when creating a view.)&lt;/FONT&gt;&lt;BR /&gt;select
    &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;t_species as v_species,&lt;/STRONG&gt;&lt;/FONT&gt;
    max(t_date) as v_date
from
    species_records
group by
    t_species&lt;/PRE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Esri Case #03526583 - FGDB aggregation database view with SQL field aliases: Field name in attribute table is incorrect when underlying table is added to map&lt;/P&gt;&lt;P&gt;Esri&amp;nbsp; Support said: "I understand that the attribute table of the database view behaves strangely and the V_SPECIES field will be shown as T_SPECIES when the SPECIES_RECORDS table is added to the map and I was able to reproduce the issue."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I had been assigning &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/manage-file-gdb/sql-reporting-and-anlysis-file-geodatabases.htm#:~:text=geodatabases%20and%20examples.-,ALIAS,-Gives%20a%20column" target="_self"&gt;aliases&lt;/A&gt;/prefixes to field names (T_ for table, V_ for view) in an attempt to avoid confusing ArcGIS Pro about whether I was referring to fields in the underlying table vs. my database view. I don't actually know if that was a problem or not; I was just trying to eliminate possible issues. But that was causing the above bug, so I'll stop using aliases where possible.&lt;/P&gt;&lt;P&gt;New view:&lt;/P&gt;&lt;PRE&gt;--latest_vw&lt;BR /&gt;select
    &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;t_species,&lt;/STRONG&gt;&lt;/FONT&gt;
    max(t_date) as &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;t_date&lt;/STRONG&gt;&lt;/FONT&gt;
from
    species_records
group by
    t_species&lt;/PRE&gt;&lt;P&gt;That view works as expected in the attribute table:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_1-1705047158298.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91385i4A85F260991F7F43/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_1-1705047158298.png" alt="Bud_1-1705047158298.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I now have the latest records per species in LATEST_VW.&lt;/P&gt;&lt;P&gt;But that view is missing all the other fields from the original table. So I want to join from LATEST_VW to the SPECIES_RECORDS table on T_SPECIES=T_SPECIES and T_DATE=T_DATE.&lt;/P&gt;&lt;P&gt;So I'll make a "view on top of a view" to join LATEST_VW with SPECIES_RECORDS, joining on multiple fields. As far as I can tell, a "view on a view" is necessary because &lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/support-correlated-subqueries-in-file-geodatabase/idi-p/1238551" target="_self"&gt;correlated subqueries aren't supported&lt;/A&gt; in FGDB SQL. I adapted the SQL from the screenshot in your (TanuHoque's) example.&lt;/P&gt;&lt;PRE&gt;--latest_with_other_fields_vw&lt;BR /&gt;select
    species_records.*,
    latest_vw.*
from
    species_records
&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;inner join&lt;/FONT&gt;&lt;/STRONG&gt;
    latest_vw
    on species_records.t_species = latest_vw.t_species &lt;BR /&gt;       and species_records.t_date = latest_vw.t_date&lt;/PRE&gt;&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;The view doesn't return any records:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_2-1705048190287.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91388iB572BC12F481A5CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_2-1705048190287.png" alt="Bud_2-1705048190287.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I change the join type from INNER JOIN to LEFT OUTER JOIN, I can see that the join wasn't successful; it just produces nulls for the LATEST_VW fields.&lt;/P&gt;&lt;PRE&gt;--latest_with_other_fields_vw&lt;BR /&gt;select
    species_records.*,
    latest_vw.*
from
    species_records
&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;left outer join&lt;/STRONG&gt;&lt;/FONT&gt;
    latest_vw
    on species_records.t_species = latest_vw.t_species &lt;BR /&gt;       and species_records.t_date = latest_vw.t_date&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_6-1705050182749.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91396iC49BCA5007632985/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_6-1705050182749.png" alt="Bud_6-1705050182749.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It should look like this (a parallel test in a mobile geodatabase):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_4-1705048989207.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91390i89095A7E35CF20AF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_4-1705048989207.png" alt="Bud_4-1705048989207.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(In the future, I could easily exclude the rows that aren't matches by using an INNER JOIN instead of a LEFT OUTER JOIN. Or in a definition query.)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My FGDB logic should work. I can prove it by converting LATEST_VW to a table called LATEST_TBL (copy the view in Catalog and paste it; it will be pasted as a table, not a view).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_5-1705049531257.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91392iCD9A6AB67C0177CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_5-1705049531257.png" alt="Bud_5-1705049531257.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In a new view called LATEST_&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;TBL&lt;/STRONG&gt;&lt;/FONT&gt;_WITH_OTHER_FIELDS_VW, I'll join using LATEST_&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;TBL&lt;/FONT&gt;&lt;/STRONG&gt; instead of LATEST_VW.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;--latest_&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;tbl&lt;/STRONG&gt;&lt;/FONT&gt;_with_other_fields_vw&lt;BR /&gt;select
    species_records.*,
    latest_&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;tbl&lt;/STRONG&gt;&lt;/FONT&gt;.*
from
    species_records
left outer join
    latest_&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;tbl&lt;/STRONG&gt;&lt;/FONT&gt;
    on species_records.t_species = latest_&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;tbl&lt;/STRONG&gt;&lt;/FONT&gt;.t_species 
       and species_records.t_date = latest_&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;tbl&lt;/STRONG&gt;&lt;/FONT&gt;.t_date&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;That worked as expected. There are matches:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_8-1705050528361.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91398iF6F08FB736535533/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_8-1705050528361.png" alt="Bud_8-1705050528361.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I think my logic is sound. But making a "view on a view" seems to be a problem.&lt;/P&gt;&lt;P&gt;Anyway, I don't want to export the view as a table. I want to use live data in a view.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Other notes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I did the exact same tests in a mobile geodatabase but didn't have the issues mentioned above. Those issues only happen in a file geodatabase. That suggests there isn't a problem with my logic.&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I haven't found a way to "break the ties" when there are multiple records per species with the same date. At least, not when using FGDB SQL (whereas it can be done in mobile or enterprise geodatabases: &lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/join-control-what-related-record-gets-used/idc-p/1239993/highlight/true#M22488" target="_self"&gt;Join — Control what related record gets used&lt;/A&gt;).&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;HR /&gt;&lt;P&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As mentioned at the beginning of this reply,&amp;nbsp;&lt;SPAN&gt;I was hoping to use Make Query Table as an alternative join mechanism (joining LATEST_VW to the SPECIES_RECORDS table) since FGDB SQL/views have limitations.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Edit:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I did a simpler test regarding "views on views". I created a simple SELECT * view on SPECIES_RECORDS called TEST_VW_1. Then I created an additional view called TEST_VW_2 that SELECTs * from TEST_VW_1. The attribute table of TEST_VW_2 is empty, which tells me that "views on views" don't work at all in FGDBs. So I think that's the root cause of my problem.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 07:26:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idc-p/1369460#M27992</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-01-15T07:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Make Query Table — Use date field in join - Status changed to: Open</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idc-p/1369939#M28015</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/351335"&gt;@Bud&lt;/a&gt;&amp;nbsp;for providing detail clarification. We appreciate this very much. I have changed it back to Open status. Also changing the label to GeoDatabase.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2024 18:55:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/make-query-table-use-date-field-in-join/idc-p/1369939#M28015</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2024-01-13T18:55:48Z</dc:date>
    </item>
  </channel>
</rss>

