<?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 Why are stats functions first() and latest() not returning the same result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-are-stats-functions-first-and-latest-not-returning-the-same/m-p/472155#M132849</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am a little bit confused by the functions &lt;CODE&gt;latest()&lt;/CODE&gt; and &lt;CODE&gt;earliest()&lt;/CODE&gt;.&lt;BR /&gt;
Running this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | stats first(myfield) latest(myfield) earliest(myfield) last(myfield) by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Gives us&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    first(myfield)      latest(myfield) earliest(myfield) last(myfield) 
    1434767753.755  1434767758.840  1383228859.223  1383228859.223
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It is, from my point of view, normal to have the same value returned by &lt;CODE&gt;earliest()&lt;/CODE&gt; and &lt;CODE&gt;last()&lt;/CODE&gt;, as we did not change the order of the events. I am surprised to receive different values for &lt;CODE&gt;first()&lt;/CODE&gt; and &lt;CODE&gt;latest()&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;If we run:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | head 1 | table myfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myfield
1434767758.840
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The value returned by &lt;CODE&gt;latest()&lt;/CODE&gt; seems to be correct. What is returned by &lt;CODE&gt;first()&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;PS - We are running on Splunk Enterprise 6.2.3&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jun 2015 22:01:11 GMT</pubDate>
    <dc:creator>afieffe</dc:creator>
    <dc:date>2015-06-20T22:01:11Z</dc:date>
    <item>
      <title>Why are stats functions first() and latest() not returning the same result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-stats-functions-first-and-latest-not-returning-the-same/m-p/472155#M132849</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am a little bit confused by the functions &lt;CODE&gt;latest()&lt;/CODE&gt; and &lt;CODE&gt;earliest()&lt;/CODE&gt;.&lt;BR /&gt;
Running this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | stats first(myfield) latest(myfield) earliest(myfield) last(myfield) by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Gives us&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    first(myfield)      latest(myfield) earliest(myfield) last(myfield) 
    1434767753.755  1434767758.840  1383228859.223  1383228859.223
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It is, from my point of view, normal to have the same value returned by &lt;CODE&gt;earliest()&lt;/CODE&gt; and &lt;CODE&gt;last()&lt;/CODE&gt;, as we did not change the order of the events. I am surprised to receive different values for &lt;CODE&gt;first()&lt;/CODE&gt; and &lt;CODE&gt;latest()&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;If we run:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | head 1 | table myfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myfield
1434767758.840
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The value returned by &lt;CODE&gt;latest()&lt;/CODE&gt; seems to be correct. What is returned by &lt;CODE&gt;first()&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;PS - We are running on Splunk Enterprise 6.2.3&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2015 22:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-stats-functions-first-and-latest-not-returning-the-same/m-p/472155#M132849</guid>
      <dc:creator>afieffe</dc:creator>
      <dc:date>2015-06-20T22:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Why are stats functions first() and latest() not returning the same result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-stats-functions-first-and-latest-not-returning-the-same/m-p/472156#M132850</link>
      <description>&lt;P&gt;&lt;CODE&gt;first()&lt;/CODE&gt; gives you the value first seen by the reporting command, with no regard for the timestamp. Depending on what's returned first to the search head from the indexers this may or may not match with &lt;CODE&gt;latest()&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2015 08:37:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-stats-functions-first-and-latest-not-returning-the-same/m-p/472156#M132850</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-06-21T08:37:14Z</dc:date>
    </item>
  </channel>
</rss>

