<?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: Most Recent Reading from Unit and Channel in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659063#M37346</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Honestly, I am a bit confused.&amp;nbsp; You are using the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/conversion-toolbox/table-to-table.htm"&gt;Table to Table tool&lt;/A&gt;, right?&amp;nbsp; And you are pasting the entire SQL above into the Expression box or are you pasting only the part after WHERE?&amp;nbsp; If one looks at the Syntax table for the tool, the "Expression" box in the GUI tool is really a "where_clause," not a general SQL box.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Nov 2015 16:29:58 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2015-11-16T16:29:58Z</dc:date>
    <item>
      <title>Most Recent Reading from Unit and Channel</title>
      <link>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659060#M37343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all. While we are waiting for GeoEvent processor to be rolled out in my organization, I am attempting to create a temporary solution to get pressure tracking data into our GIS system to be made available to our end-users. I have the workflow planned out, but the only thing in my way is getting the most recent readings into a seperate table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a SQL Server database that holds all of the readings in a single table, which contains over 2 million rows. Data is held in the table per reading date, UDI (device identifier), channel (3 channels per device), and value (actual readings).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the process will be scripted in python, I am trying to automate the copying of the most recent readings from this table into a new table. I am using the Table to Table tool, with a SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;Here is the code I am trying to use, which seems to work well inside of SQL Server:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select UDI,Channel,Value, DateTime_UTC&lt;/P&gt;&lt;P&gt;from PTData4 t1&lt;/P&gt;&lt;P&gt;WHERE EXISTS(SELECT 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM PTData4 t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE t2.UDI = t1.UDI&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; AND t2.Channel = t1.Channel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY t2.UDI,&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; t2.Channel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVING t1.DateTime_UTC = MAX(t2.DateTime_UTC))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However in ArcGIS I get an error that states: "There was an error with the expression. Failed to parse the where clause."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas how to convert this code to be compatible with ArcGIS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 20:07:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659060#M37343</guid>
      <dc:creator>MarcCusumano</dc:creator>
      <dc:date>2015-11-13T20:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Most Recent Reading from Unit and Channel</title>
      <link>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659061#M37344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide the specific Python code?&amp;nbsp; Although you have provided the SQL code that works directly in SQL Server, it is helpful to see how you are creating/building the arguments and passing them to the tool.&amp;nbsp; And, please use Syntax Highlighting with your code, it makes it much easier to read, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Nov 2015 17:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659061#M37344</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-11-14T17:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Most Recent Reading from Unit and Channel</title>
      <link>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659062#M37345</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;SELECT UDI,Channel,Value, DateTime_UTC
FROM PTData4 t1
WHERE EXISTS(SELECT 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM PTData4 t2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE t2.UDI = t1.UDI
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND t2.Channel = t1.Channel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY t2.UDI,
&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; t2.Channel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVING t1.DateTime_UTC = MAX(t2.DateTime_UTC))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to work in ArcCatalog, but the results are not expected (I am getting readings from different dates for each device and channel):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;DateTime_UTC in (SELECT max( DateTime_UTC ) 
FROM PT_RO_Pressure_Tracker_Interval_Data 
GROUP BY UDI, Channel)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have not tried any automation in Python yet; I would first like to get the extract working in Table to Table before attempting automation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659062#M37345</guid>
      <dc:creator>MarcCusumano</dc:creator>
      <dc:date>2021-12-12T03:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Most Recent Reading from Unit and Channel</title>
      <link>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659063#M37346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Honestly, I am a bit confused.&amp;nbsp; You are using the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/conversion-toolbox/table-to-table.htm"&gt;Table to Table tool&lt;/A&gt;, right?&amp;nbsp; And you are pasting the entire SQL above into the Expression box or are you pasting only the part after WHERE?&amp;nbsp; If one looks at the Syntax table for the tool, the "Expression" box in the GUI tool is really a "where_clause," not a general SQL box.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2015 16:29:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/most-recent-reading-from-unit-and-channel/m-p/659063#M37346</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-11-16T16:29:58Z</dc:date>
    </item>
  </channel>
</rss>

