<?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: Data Load Sql in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992794#M338148</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt="2015-10-05 #1.PNG" class="jive-image image-1" src="/legacyfs/online/100963_2015-10-05 #1.PNG" style="height: 815px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Oct 2015 12:37:25 GMT</pubDate>
    <dc:creator>petter</dc:creator>
    <dc:date>2015-10-05T12:37:25Z</dc:date>
    <item>
      <title>Data Load Sql</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992792#M338146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to take data from 2 different tables but I couldn't succeeded. Here is my code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;VOUCHER:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;LOAD *&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;select bi.id,o.total_voucher, bi.persisted_price * bi.quantity, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;round((o.total_voucher * bi.persisted_price * bi.quantity) / total , 2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;from order_order o, order_basketitem bi, (&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;select oo.id as o_id, sum(bii.persisted_price * bii.quantity) as total&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;from order_order oo, order_basketitem bii&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;where oo.id = bii.order_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;and oo.persisted_tracker_code = '127707332191417'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;group by 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;) as xx&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;where o.id = bi.order_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;and o.persisted_tracker_code = '127707332191417'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;and xx.o_id = o.id&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;this one works, but when I try to remove &amp;lt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13.3333px;"&gt;and o.persisted_tracker_code = '127707332191417'&amp;gt; filter, i get an error like &amp;lt;division by zero&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px; font-family: Calibri, sans-serif;"&gt;and also when it works, this table doesn't set up any relation with other tables. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;How can I fixed these issues? Can you help me please.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;Berker.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 06:12:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992792#M338146</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-05T06:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Data Load Sql</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992793#M338147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason you get a divison by zero is in your SQL code as you calculate a total with this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(bii.persisted_price * bii.quantity) as total&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;and then further up in the SQL this calculated column is used in a division:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;(o.total_voucher * bi.persisted_price * bi.quantity) / total &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if the first sum will be 0 for any id you will get this error. And by "luck" the persisted_tracker_code = '&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13.3333px;"&gt;127707332191417' does not return a 0 and for that reason calculates without an error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to modify your SQL to cater for the fact that you might get a total of zero - maybe return a 0 or null like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case total when 0 then 0 else &lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;(o.total_voucher * bi.persisted_price * bi.quantity) / total&amp;nbsp; end&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your SQL could look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;select bi.id,o.total_voucher, bi.persisted_price * bi.quantity,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="color: black; font-style: inherit; font-family: Calibri, sans-serif; text-decoration: line-through; font-weight: inherit;"&gt;round((o.total_voucher * bi.persisted_price * bi.quantity) / total , 2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;STRONG&gt;case total when 0 then 0 else &lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;round(&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;(o.total_voucher * bi.persisted_price * bi.quantity) / total ,2) end&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;from order_order o, order_basketitem bi, (&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;select oo.id as o_id, sum(bii.persisted_price * bii.quantity) as total&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;from order_order oo, order_basketitem bii&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;where oo.id = bii.order_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="color: black; font-style: inherit; font-family: Calibri, sans-serif; text-decoration: line-through; font-weight: inherit;"&gt;and oo.persisted_tracker_code = '127707332191417'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;group by 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;) as xx&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;where o.id = bi.order_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="color: black; font-style: inherit; font-family: Calibri, sans-serif; text-decoration: line-through; font-weight: inherit;"&gt;and o.persisted_tracker_code = '127707332191417'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background: white;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Calibri, sans-serif; color: black;"&gt;and xx.o_id = o.id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lastly - for association:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will have to rename your returned column from the SQL so it match some other table's column in the LOAD statement or in the SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri, sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 12:35:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992793#M338147</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-10-05T12:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Data Load Sql</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992794#M338148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt="2015-10-05 #1.PNG" class="jive-image image-1" src="/legacyfs/online/100963_2015-10-05 #1.PNG" style="height: 815px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 12:37:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992794#M338148</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-10-05T12:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Data Load Sql</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992795#M338149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much, it worked perfect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i'll try to optimize Load statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Oct 2015 05:33:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Load-Sql/m-p/992795#M338149</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-06T05:33:41Z</dc:date>
    </item>
  </channel>
</rss>

