<?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: Help me with search query command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298764#M90062</link>
    <description>&lt;P&gt;You should try to do this in one query and not using &lt;CODE&gt;join&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc (sourcetype=abc OR sourcetype=pqr) ID=* 
| fields ID userName sourcetype
| stats values(userName) as userName count(eval(sourcetype=="pqr")) as Count by ID 
| table userName ID Count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 May 2017 14:34:52 GMT</pubDate>
    <dc:creator>rjthibod</dc:creator>
    <dc:date>2017-05-17T14:34:52Z</dc:date>
    <item>
      <title>Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298759#M90057</link>
      <description>&lt;P&gt;help me with JOIN query for my usecase&lt;BR /&gt;
i  have &lt;BR /&gt;
index=abc sourcetype=abc&lt;BR /&gt;
index=abc sourcetype=pqr&lt;/P&gt;

&lt;P&gt;In sourcetype=abc i have fields userName and ID.&lt;BR /&gt;
In sourcetype=pqr i have fields ID and i want to know count made by the ID&lt;/P&gt;

&lt;P&gt;i want to display it in a table like&lt;/P&gt;

&lt;P&gt;userName ID count&lt;BR /&gt;
name1     101    3&lt;BR /&gt;
name2     102    2&lt;BR /&gt;
name3     103    1&lt;/P&gt;

&lt;P&gt;please help me with join query&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2950i9547001B2D899289/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298759#M90057</guid>
      <dc:creator>sravankaripe</dc:creator>
      <dc:date>2017-05-17T14:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298760#M90058</link>
      <description>&lt;P&gt;Maybe this would helpful&lt;/P&gt;

&lt;P&gt;index=abc sourcetype=abc OR index=abc sourcetype=pqr | stats count as Count by ID&lt;BR /&gt;
 | join  type=left ID [search index=abc sourcetype=abc | stats latest(userName) as userName by ID] | table userName ID Count&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:24:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298760#M90058</guid>
      <dc:creator>andrey2007</dc:creator>
      <dc:date>2017-05-17T14:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298761#M90059</link>
      <description>&lt;P&gt;For some clarification, is count a field in sourcetype pqr, or do you need to perform a count?&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298761#M90059</guid>
      <dc:creator>kmorris_splunk</dc:creator>
      <dc:date>2017-05-17T14:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298762#M90060</link>
      <description>&lt;P&gt;Don't use a join if you can avoid it.  In this case, you do this ---&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc (sourcetype=abc OR sourcetype=pqr)
| fields userName ID 
| eval mycount=if(sourcetype=abc,0,1)
| stats values(userName) as userName, sum(mycount) as mycount by ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The records from abc will have a value in the userName field, and for the ones from pqr that field will be NULL.&lt;BR /&gt;
The records from abc will have 0 in the mycount field, and for the ones from pqr that field will be 1.&lt;BR /&gt;
Stats will therefore give you the count of pqr and the userName value of abc.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:31:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298762#M90060</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-17T14:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298763#M90061</link>
      <description>&lt;P&gt;@andrey2007 - Your first stats command's count will include a count of the records in abc.  OP wants the count from pqr only.  Remove the sourcetype=abc from the first portion of the query to get the desired answer.  Also, see my answer for a non-join method that will avoid the limit on subsearches.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:34:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298763#M90061</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-17T14:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298764#M90062</link>
      <description>&lt;P&gt;You should try to do this in one query and not using &lt;CODE&gt;join&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc (sourcetype=abc OR sourcetype=pqr) ID=* 
| fields ID userName sourcetype
| stats values(userName) as userName count(eval(sourcetype=="pqr")) as Count by ID 
| table userName ID Count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2017 14:34:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298764#M90062</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-05-17T14:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298765#M90063</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc (sourcetype="abc" OR sourcetype="pqr")
| stats values(username) AS userName count BY ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2017 15:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298765#M90063</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-17T15:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298766#M90064</link>
      <description>&lt;P&gt;Looks that "if" has no sense because "fields" command  deleted sourcetype field and mycount is always equals to "1"&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 08:36:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298766#M90064</guid>
      <dc:creator>andrey2007</dc:creator>
      <dc:date>2017-05-19T08:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with search query command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298767#M90065</link>
      <description>&lt;P&gt;Sure, you are right "index=abc sourcetype=abc OR index=abc sourcetype=pqr" should be changed to something like "index=abc (sourcetype=abc OR sourcetype=pqr )"&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 08:38:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-me-with-search-query-command/m-p/298767#M90065</guid>
      <dc:creator>andrey2007</dc:creator>
      <dc:date>2017-05-19T08:38:29Z</dc:date>
    </item>
  </channel>
</rss>

