<?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 SQL Temp table Query in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SQL-Temp-table-Query/m-p/435173#M699245</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whats the best way to handle this query in sql? I have two previous queries that I union together and forms a temp table. Now this query takes the temp table then joins to more tables for the final result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is that the last query has multiple dimensions that look at the temp and the newly joined tables like below. I just can't wrap my head around the best way to handle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I create multiple different load statments and concatanate them together? And then join the two temp tables together. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;when b.PAProjectType = 1 then case when a.pabllngtype = 1 then a.BillRate * a.quantity else c.PAFFProfitAmount * a.quantity end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else c.paffprofitamount * a.quantity&lt;/P&gt;&lt;P&gt;END as StdRevenue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from @projDetails a&lt;/P&gt;&lt;P&gt;left outer join BWIT..PA01201 b on a.paprojnumber = b.paprojnumber&lt;/P&gt;&lt;P&gt;left outer join BWIT..RM00101 rm on rm.CUSTNMBR = b.CUSTNMBR&lt;/P&gt;&lt;P&gt;left outer join BWIT..UPR00100 upr on upr.EMPLOYID = a.employid&lt;/P&gt;&lt;P&gt;left outer join BWIT..PA00601 c on upr.employid = c.employid&lt;/P&gt;&lt;P&gt;left outer join GPCustom..BacklogReportBranches brb on brb.Department = upr.DEPRTMNT&lt;/P&gt;&lt;P&gt;left outer join GPCustom..Regions reg on reg.RegionID = brb.RegionID&lt;/P&gt;&lt;P&gt;where PADT between @startDate and @endDate&lt;/P&gt;&lt;P&gt;and b.paprojnumber like @projNum + '%'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any guidance would be helpful. The full stored procedure is below.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Dec 2012 16:25:12 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-12-13T16:25:12Z</dc:date>
    <item>
      <title>SQL Temp table Query</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Temp-table-Query/m-p/435173#M699245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whats the best way to handle this query in sql? I have two previous queries that I union together and forms a temp table. Now this query takes the temp table then joins to more tables for the final result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is that the last query has multiple dimensions that look at the temp and the newly joined tables like below. I just can't wrap my head around the best way to handle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I create multiple different load statments and concatanate them together? And then join the two temp tables together. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;when b.PAProjectType = 1 then case when a.pabllngtype = 1 then a.BillRate * a.quantity else c.PAFFProfitAmount * a.quantity end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else c.paffprofitamount * a.quantity&lt;/P&gt;&lt;P&gt;END as StdRevenue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from @projDetails a&lt;/P&gt;&lt;P&gt;left outer join BWIT..PA01201 b on a.paprojnumber = b.paprojnumber&lt;/P&gt;&lt;P&gt;left outer join BWIT..RM00101 rm on rm.CUSTNMBR = b.CUSTNMBR&lt;/P&gt;&lt;P&gt;left outer join BWIT..UPR00100 upr on upr.EMPLOYID = a.employid&lt;/P&gt;&lt;P&gt;left outer join BWIT..PA00601 c on upr.employid = c.employid&lt;/P&gt;&lt;P&gt;left outer join GPCustom..BacklogReportBranches brb on brb.Department = upr.DEPRTMNT&lt;/P&gt;&lt;P&gt;left outer join GPCustom..Regions reg on reg.RegionID = brb.RegionID&lt;/P&gt;&lt;P&gt;where PADT between @startDate and @endDate&lt;/P&gt;&lt;P&gt;and b.paprojnumber like @projNum + '%'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any guidance would be helpful. The full stored procedure is below.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 16:25:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Temp-table-Query/m-p/435173#M699245</guid>
      <dc:creator />
      <dc:date>2012-12-13T16:25:12Z</dc:date>
    </item>
  </channel>
</rss>

