<?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 Nested SubQuery With NOT IN Clause in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622022#M216202</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am looking for the equivalent of performing SQL like such:&lt;/P&gt;&lt;P&gt;SELECT transaction_id, vendor&lt;BR /&gt;FROM orders&lt;BR /&gt;WHERE transaction_id NOT IN (SELECT transaction_id FROM events).&lt;/P&gt;&lt;P&gt;As of right now I can construct a list of transaction_ids for orders in one search query and a list of transaction_ids for events in another search query, but my ultimate goal is to return order logs that do not share transaction_ids with the transaction_ids of the events log. Any help is greatly appreciated, thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 24 Nov 2022 18:14:03 GMT</pubDate>
    <dc:creator>ayu2375</dc:creator>
    <dc:date>2022-11-24T18:14:03Z</dc:date>
    <item>
      <title>Nested SubQuery With NOT IN Clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622022#M216202</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am looking for the equivalent of performing SQL like such:&lt;/P&gt;&lt;P&gt;SELECT transaction_id, vendor&lt;BR /&gt;FROM orders&lt;BR /&gt;WHERE transaction_id NOT IN (SELECT transaction_id FROM events).&lt;/P&gt;&lt;P&gt;As of right now I can construct a list of transaction_ids for orders in one search query and a list of transaction_ids for events in another search query, but my ultimate goal is to return order logs that do not share transaction_ids with the transaction_ids of the events log. Any help is greatly appreciated, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 18:14:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622022#M216202</guid>
      <dc:creator>ayu2375</dc:creator>
      <dc:date>2022-11-24T18:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SubQuery With NOT IN Clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622038#M216212</link>
      <description>&lt;P&gt;Splunk has written a manual to help SQL users transition to SPL.&amp;nbsp; See &lt;A href="https://docs.splunk.com/Documentation/Splunk/9.0.2/SearchReference/SQLtoSplunk" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.0.2/SearchReference/SQLtoSplunk&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The NOT IN construct in SQL can be expressed as NOT and a subsearch.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=orders vendor=* NOT [ index=events transaction_id=* | fields transaction_id ]&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 25 Nov 2022 02:07:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622038#M216212</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-25T02:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SubQuery With NOT IN Clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622040#M216213</link>
      <description>&lt;P&gt;There are many ways to do this, but the most appropriate method depends a lot on the actual data. &amp;nbsp;You really want to illustrate the dataset and explain the outcome, maybe with mockups. &amp;nbsp;It is fine to illustrate some ideas using a different language. &amp;nbsp;But how would orders and events be represented in Splunk, for example? &amp;nbsp;Do transaction_id and vendor already exist in data sources or is there some maneuver to extract them? &amp;nbsp;Such details can make a difference because SPL is fundamentally different from SQL.&lt;/P&gt;&lt;P&gt;Assuming orders and events are from two sourcetypes and fields are already extracted, you can do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype IN (orders, events)
| stats values(sourcetype) as sourcetype values(vendor) as vendor by transaction_id
| where sourcetype == events and mvcount(sourcetype) &amp;gt; 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2022 02:33:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Nested-SubQuery-With-NOT-IN-Clause/m-p/622040#M216213</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-25T02:33:51Z</dc:date>
    </item>
  </channel>
</rss>

