<?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 2 sql tables joined and hierarchized in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233122#M84666</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;there are 2 sql tables: Table_1 includes transactions, Table_2 includes accounts hierarchy like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; padding-left: 30px"&gt;Table_1&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;T1_AccountId, T1_Amount&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2, 51&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;3, 61&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; padding-left: 30px"&gt;Table_2&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;T2_AccountId, T2_AccountParentId, T2_AccountName&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;1, , Sales&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2, 1, Apples&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;3, 1, Pears&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;I need to join and hierarchize them like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; padding-left: 30px"&gt;Table_Joined&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;AccountId, AccountName, AccountName1, Amount&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2, Sales, Apples, 51&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;3, Sales, Pears, 61&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that when the code is defined as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;B&gt;HIERARCHY&lt;/B&gt; (T2_AccountId, T2_AccountParentId, T2_AccountName)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;B&gt;SELECT&lt;/B&gt; T2_AccountId, T2_AccountParentId, T2_AccountName, T1_Amount&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;B&gt;FROM&lt;/B&gt; Table_1 LEFT JOIN Table_2 ON Table_1.AccountId = Table_2.AccountId&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;the majority of data gets lost and when RIGHT JOIN is used HIERARCHY gets lost. Due to the other parts of the code the two tables must be joined into one. Do you have an idea how to make it right?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Przemek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 10 Oct 2010 15:45:07 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-10-10T15:45:07Z</dc:date>
    <item>
      <title>2 sql tables joined and hierarchized</title>
      <link>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233122#M84666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;there are 2 sql tables: Table_1 includes transactions, Table_2 includes accounts hierarchy like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; padding-left: 30px"&gt;Table_1&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;T1_AccountId, T1_Amount&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2, 51&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;3, 61&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; padding-left: 30px"&gt;Table_2&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;T2_AccountId, T2_AccountParentId, T2_AccountName&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;1, , Sales&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2, 1, Apples&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;3, 1, Pears&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;I need to join and hierarchize them like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; padding-left: 30px"&gt;Table_Joined&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;AccountId, AccountName, AccountName1, Amount&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2, Sales, Apples, 51&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;3, Sales, Pears, 61&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that when the code is defined as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;B&gt;HIERARCHY&lt;/B&gt; (T2_AccountId, T2_AccountParentId, T2_AccountName)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;B&gt;SELECT&lt;/B&gt; T2_AccountId, T2_AccountParentId, T2_AccountName, T1_Amount&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;B&gt;FROM&lt;/B&gt; Table_1 LEFT JOIN Table_2 ON Table_1.AccountId = Table_2.AccountId&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;the majority of data gets lost and when RIGHT JOIN is used HIERARCHY gets lost. Due to the other parts of the code the two tables must be joined into one. Do you have an idea how to make it right?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Przemek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Oct 2010 15:45:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233122#M84666</guid>
      <dc:creator />
      <dc:date>2010-10-10T15:45:07Z</dc:date>
    </item>
    <item>
      <title>2 sql tables joined and hierarchized</title>
      <link>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233123#M84667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Przemek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way to do this would be join the tables first and then create the hierarchy load from the resident table.&lt;/P&gt;&lt;P&gt;like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;&lt;BR /&gt;SET ThousandSep=',';&lt;BR /&gt;SET DecimalSep='.';&lt;BR /&gt;SET MoneyThousandSep=',';&lt;BR /&gt;SET MoneyDecimalSep='.';&lt;BR /&gt;SET MoneyFormat='$#,##0.00;($#,##0.00)';&lt;BR /&gt;SET TimeFormat='h:mm:ss TT';&lt;BR /&gt;SET DateFormat='M/D/YYYY';&lt;BR /&gt;SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';&lt;BR /&gt;SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';&lt;BR /&gt;SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';&lt;BR /&gt;&lt;BR /&gt;Table1:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;&lt;BR /&gt;AccountID, Amount&lt;BR /&gt;2,51&lt;BR /&gt;3,61&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;inner join&lt;BR /&gt;Table2:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;&lt;BR /&gt;AccountID, AccountParentID, AccountName&lt;BR /&gt;1,,Sales&lt;BR /&gt;2,1,Apples&lt;BR /&gt;3,1,Pears&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hierarchy(AccountID, AccountParentID, AccountName) load *&lt;BR /&gt;resident Table1;&lt;BR /&gt;&lt;BR /&gt;drop table Table1;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Oct 2010 21:36:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233123#M84667</guid>
      <dc:creator>mantaq10</dc:creator>
      <dc:date>2010-10-10T21:36:05Z</dc:date>
    </item>
    <item>
      <title>2 sql tables joined and hierarchized</title>
      <link>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233124#M84668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And here is the attached qvw...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Oct 2010 21:38:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/2-sql-tables-joined-and-hierarchized/m-p/233124#M84668</guid>
      <dc:creator>mantaq10</dc:creator>
      <dc:date>2010-10-10T21:38:24Z</dc:date>
    </item>
  </channel>
</rss>

