<?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: joining multiple select statements in dbxquery in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337629#M164387</link>
    <description>&lt;P&gt;Thanks a lot for your input&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2017 13:45:36 GMT</pubDate>
    <dc:creator>kishen2017</dc:creator>
    <dc:date>2017-12-12T13:45:36Z</dc:date>
    <item>
      <title>joining multiple select statements in dbxquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337626#M164384</link>
      <description>&lt;P&gt;How to join multiple select statements in dbxquery&lt;BR /&gt;
Need to display output as&lt;BR /&gt;
Total Defects 532&lt;BR /&gt;
Open defects 147&lt;BR /&gt;
Closed defect 385&lt;BR /&gt;
I have individual select statements for each row&lt;BR /&gt;
select count(bug_id) as "Total Defects" from bug&lt;BR /&gt;
select count(bug_status) as "Open defects" from bug where bug_status='Open'&lt;BR /&gt;
select count(bug_status) as "Open defects" from bug where bug_status='Close'&lt;/P&gt;

&lt;P&gt;Need to know how to join these individual select statements on dbxquery to produce output as mentioned.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:13:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337626#M164384</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2020-09-29T17:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: joining multiple select statements in dbxquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337627#M164385</link>
      <description>&lt;P&gt;can you try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|dbxquery connection=db maxrows=0 shortnames=t query="select bug_id, bug_status from bug where bug_status in('Open','Close')"|eval open_defects=if(bug_status="Open",1,0)|eval closed_defects=if(bug_status="Close",1,0)|stats count(bug_id) as "Total Defects" sum(open_defects) as "Open Defects" sum(closed_defects) as "Closed Defects"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2017 13:20:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337627#M164385</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-12-12T13:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: joining multiple select statements in dbxquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337628#M164386</link>
      <description>&lt;P&gt;Hi Kishen2017,&lt;/P&gt;

&lt;P&gt;This is possible in Splunk. Try to construct your query like the below format. &lt;/P&gt;

&lt;P&gt;| dbxquery query="select count(bug_id) as "Total Defects" from bug" connection="your connection name" | appendcols [| dbxquery query="select count(bug_status) as "Open defects" from bug where bug_status='Open'" connection="your connection name" ] | appendcols [| dbxquery query="select count(bug_status) as "Open defects" from bug where bug_status='Close'" connection="your connection name"] &lt;/P&gt;

&lt;P&gt;You can try by replacing append with appendcols also. (this is as per your convenient)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:13:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337628#M164386</guid>
      <dc:creator>sandyIscream</dc:creator>
      <dc:date>2020-09-29T17:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: joining multiple select statements in dbxquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337629#M164387</link>
      <description>&lt;P&gt;Thanks a lot for your input&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 13:45:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337629#M164387</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-12-12T13:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: joining multiple select statements in dbxquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337630#M164388</link>
      <description>&lt;P&gt;Thanks a lot for your input&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 13:46:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337630#M164388</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-12-12T13:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: joining multiple select statements in dbxquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337631#M164389</link>
      <description>&lt;P&gt;Another alternative would be to use the SQL UNION operator. So you'd have a single dbxquery that executed the SQL statement&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select count(bug_id) as "Total Defects" from bug
UNION
select count(bug_status) as "Open defects" from bug where bug_status='Open'
UNION
select count(bug_status) as "Open defects" from bug where bug_status='Close'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 13:54:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/joining-multiple-select-statements-in-dbxquery/m-p/337631#M164389</guid>
      <dc:creator>davebrooking</dc:creator>
      <dc:date>2017-12-12T13:54:35Z</dc:date>
    </item>
  </channel>
</rss>

