<?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 write subquery in splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-subquery-in-splunk/m-p/108954#M28410</link>
    <description>&lt;P&gt;I think you may do it all in one search for this use case:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index="test" sourcetype="power_test" 
| chart max(Power) as max_power first(Power) as recent_power over host 
| sort 10 -max(Power)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 May 2011 16:13:14 GMT</pubDate>
    <dc:creator>bwooden</dc:creator>
    <dc:date>2011-05-26T16:13:14Z</dc:date>
    <item>
      <title>How to write subquery in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-subquery-in-splunk/m-p/108953#M28409</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am drawing a view having one table. My table has two columns host and max(power). I want to add one more column which has latest value of the particular host. My module is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;module name="HiddenSearch" layoutPanel="panel_row2_col2" group="Power Usage" autoRun="True"&amp;gt;
    &amp;lt;param name="search"&amp;gt;index="test" sourcetype="power_test"[search index="test" sourcetype="power_test" | chart max(Power) as powerc over host | sort -Date,-Time] | fields powerc | chart max(Power),max(powerc) over host | sort 10 -max(Power)&amp;lt;/param&amp;gt;
    &amp;lt;param name="groupLabel"&amp;gt;Power Usage&amp;lt;/param&amp;gt;
    &amp;lt;module name="ViewstateAdapter"&amp;gt;
        &amp;lt;module name="HiddenFieldPicker"&amp;gt;
        &amp;lt;param name="strictMode"&amp;gt;True&amp;lt;/param&amp;gt;
        &amp;lt;module name="JobProgressIndicator"&amp;gt;
          &amp;lt;module name="EnablePreview"&amp;gt;
            &amp;lt;param name="enable"&amp;gt;True&amp;lt;/param&amp;gt;
            &amp;lt;param name="display"&amp;gt;False&amp;lt;/param&amp;gt;
            &amp;lt;module name="SimpleResultsTable"&amp;gt;
              &amp;lt;param name="allowTransformedFieldSelect"&amp;gt;True&amp;lt;/param&amp;gt;
            &amp;lt;/module&amp;gt;
          &amp;lt;/module&amp;gt;
        &amp;lt;/module&amp;gt;


      &amp;lt;/module&amp;gt;
    &amp;lt;/module&amp;gt;
&amp;lt;/module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to write sub-query which will return latest value of a particular host. That's why i am trying to sort by date and time. &lt;/P&gt;

&lt;P&gt;But query is giving zero results. Please correct me.&lt;/P&gt;

&lt;P&gt;Thanks in advance,&lt;/P&gt;

&lt;P&gt;Geetanjali &lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2011 12:59:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-subquery-in-splunk/m-p/108953#M28409</guid>
      <dc:creator>geetanjali</dc:creator>
      <dc:date>2011-05-26T12:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to write subquery in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-subquery-in-splunk/m-p/108954#M28410</link>
      <description>&lt;P&gt;I think you may do it all in one search for this use case:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index="test" sourcetype="power_test" 
| chart max(Power) as max_power first(Power) as recent_power over host 
| sort 10 -max(Power)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 May 2011 16:13:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-subquery-in-splunk/m-p/108954#M28410</guid>
      <dc:creator>bwooden</dc:creator>
      <dc:date>2011-05-26T16:13:14Z</dc:date>
    </item>
  </channel>
</rss>

