<?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 join two table with aggrouped date value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629227#M218567</link>
    <description>&lt;P&gt;Sorry for the SQL, i have my data in Relational database and for B.I. query i want to use splunk so i'm importing all the data from tables in the relational database from splunk (1 table= become 1 index). So i'm basic strugle the construct more complex query's that use multiple features, in that case i managed to get the answer:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=reserved_units_new_stock
| eval date=strftime(_time, "%y-%m-%d %H")
| STATS COUNT AS count_reserved_units BY date  
| JOIN type=left date 

  [SEARCH index=units_new_stock
    | eval date=strftime(_time, "%y-%m-%d %H")
    | STATS COUNT AS count_units1 BY date]
|eval count_units=coalesce(count_units1,0)
|eval porcentagem=round((count_units/count_reserved_units)*100,2)
| FIELDS count_units,count_reserved_units, date, porcentagem&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 01 Feb 2023 20:29:56 GMT</pubDate>
    <dc:creator>arriel96</dc:creator>
    <dc:date>2023-02-01T20:29:56Z</dc:date>
    <item>
      <title>How to join two table with aggrouped date value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/628996#M218482</link>
      <description>&lt;P&gt;A have two tables anda i want to relation this two tables by nember of events in a hour, i&amp;nbsp; manage to make a SQL query,&amp;nbsp; but struggle to do in splank. I send the data of this 2 tables for two diferent indexes (simple copy) and want to make this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;WITH count_reserved as (
    SELECT  count (ru.id) reserved,
        to_char(ru.date,'yyyy-mm-dd hh24') as time
    FROM  reserved ru
    GROUP   BY to_char(ru.date,'yyyy-mm-dd hh24')   

),
count_concluid as (
    SELECT  count (u.id) as concluid,
        to_char(u.date,'yyyy-mm-dd hh24') as time
    FROM  concluid u

    GROUP   BY to_char(u.date,'yyyy-mm-dd hh24')    
)
SELECT  coalesce(concluid,0) as concluid,
    reserved,
    count_reserved.time,
    ((coalesce(concluid::decimal,0)/reserved)*100) as percentage
FROM  count_reserved
    
    LEFT JOIN 
    count_concluid
    ON count_concluid.time=count_reserved.time
ORDER BY 3 ASC&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the information that a want to return is the percentage value and the time to make a graph hour bar&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 14:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/628996#M218482</guid>
      <dc:creator>arriel96</dc:creator>
      <dc:date>2023-01-31T14:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two table with aggrouped date value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629081#M218511</link>
      <description>&lt;P&gt;Have you consulted&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk" target="_blank" rel="noopener"&gt;Splunk SPL for SQL users&lt;/A&gt;? What is the sample code attempted? &amp;nbsp;If you want to get concrete help, you will also need to illustrate the data in your index, illustrate the result you want (and not make people reverse engineer from some SQL code), and illustrate the result from your sample code, and compare to your desired result.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 05:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629081#M218511</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-01T05:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two table with aggrouped date value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629227#M218567</link>
      <description>&lt;P&gt;Sorry for the SQL, i have my data in Relational database and for B.I. query i want to use splunk so i'm importing all the data from tables in the relational database from splunk (1 table= become 1 index). So i'm basic strugle the construct more complex query's that use multiple features, in that case i managed to get the answer:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=reserved_units_new_stock
| eval date=strftime(_time, "%y-%m-%d %H")
| STATS COUNT AS count_reserved_units BY date  
| JOIN type=left date 

  [SEARCH index=units_new_stock
    | eval date=strftime(_time, "%y-%m-%d %H")
    | STATS COUNT AS count_units1 BY date]
|eval count_units=coalesce(count_units1,0)
|eval porcentagem=round((count_units/count_reserved_units)*100,2)
| FIELDS count_units,count_reserved_units, date, porcentagem&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 20:29:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629227#M218567</guid>
      <dc:creator>arriel96</dc:creator>
      <dc:date>2023-02-01T20:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two table with aggrouped date value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629306#M218605</link>
      <description>&lt;P&gt;Does this mean the question is answered? &amp;nbsp;In general, using join should be the last resort. &amp;nbsp;But if it works for you, you do not have to change, not while you are learning to use SPL.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 09:41:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629306#M218605</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-02T09:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two table with aggrouped date value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629326#M218618</link>
      <description>&lt;P&gt;Yes it's resolve , yanks for the attention&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 13:07:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-table-with-aggrouped-date-value/m-p/629326#M218618</guid>
      <dc:creator>arriel96</dc:creator>
      <dc:date>2023-02-02T13:07:18Z</dc:date>
    </item>
  </channel>
</rss>

