<?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 Best way to write load script which uses the same CTE multiple times！！！ in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094498#M363677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the same CTE statement (query to get patients) for multiple times in my load script in order to get different information like lab test, visit info, medication. I think there might be a way to avoid this duplication. I heard about QVD, not sure whether it is a good choice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Longmatch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code like this:&lt;/P&gt;&lt;P&gt;Patient:&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;WITH Patients as (&lt;/P&gt;&lt;P&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P&gt;FROM patient&lt;/P&gt;&lt;P&gt;WHERE age &amp;gt;18&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from Patient;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Medication:&lt;/P&gt;&lt;P&gt;SQL &lt;/P&gt;&lt;P&gt;WITH Patients as (&lt;/P&gt;&lt;P&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P&gt;FROM patient &lt;/P&gt;&lt;P&gt;WHERE age &amp;gt;18&lt;/P&gt;&lt;P&gt;) &lt;/P&gt;&lt;P&gt;select patient_id, medication&lt;/P&gt;&lt;P&gt;from medication a&lt;/P&gt;&lt;P&gt;inner join patients b on a.patient_id = b.patient_id;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lab:&lt;/P&gt;&lt;P&gt;SQL &lt;/P&gt;&lt;P&gt;WITH Patients as (&lt;/P&gt;&lt;P&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P&gt;FROM patient &lt;/P&gt;&lt;P&gt;WHERE age &amp;gt;18&lt;/P&gt;&lt;P&gt;) &lt;/P&gt;&lt;P&gt;select patient_id, labTest&lt;/P&gt;&lt;P&gt;from labTest a&lt;/P&gt;&lt;P&gt;inner join patients b on a.patient_id = b.patient_id;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jan 2016 00:14:50 GMT</pubDate>
    <dc:creator>baylor2016</dc:creator>
    <dc:date>2016-01-15T00:14:50Z</dc:date>
    <item>
      <title>Best way to write load script which uses the same CTE multiple times！！！</title>
      <link>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094498#M363677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the same CTE statement (query to get patients) for multiple times in my load script in order to get different information like lab test, visit info, medication. I think there might be a way to avoid this duplication. I heard about QVD, not sure whether it is a good choice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Longmatch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code like this:&lt;/P&gt;&lt;P&gt;Patient:&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;WITH Patients as (&lt;/P&gt;&lt;P&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P&gt;FROM patient&lt;/P&gt;&lt;P&gt;WHERE age &amp;gt;18&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from Patient;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Medication:&lt;/P&gt;&lt;P&gt;SQL &lt;/P&gt;&lt;P&gt;WITH Patients as (&lt;/P&gt;&lt;P&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P&gt;FROM patient &lt;/P&gt;&lt;P&gt;WHERE age &amp;gt;18&lt;/P&gt;&lt;P&gt;) &lt;/P&gt;&lt;P&gt;select patient_id, medication&lt;/P&gt;&lt;P&gt;from medication a&lt;/P&gt;&lt;P&gt;inner join patients b on a.patient_id = b.patient_id;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lab:&lt;/P&gt;&lt;P&gt;SQL &lt;/P&gt;&lt;P&gt;WITH Patients as (&lt;/P&gt;&lt;P&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P&gt;FROM patient &lt;/P&gt;&lt;P&gt;WHERE age &amp;gt;18&lt;/P&gt;&lt;P&gt;) &lt;/P&gt;&lt;P&gt;select patient_id, labTest&lt;/P&gt;&lt;P&gt;from labTest a&lt;/P&gt;&lt;P&gt;inner join patients b on a.patient_id = b.patient_id;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 00:14:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094498#M363677</guid>
      <dc:creator>baylor2016</dc:creator>
      <dc:date>2016-01-15T00:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to write load script which uses the same CTE multiple times！！！</title>
      <link>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094499#M363678</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;Try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Patient:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SELECT patient_id, patient_name, patient_age&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM patient&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE age &amp;gt;18;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Medication:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LEFT KEEP(Patient)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;select patient_id, medication&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;from medication;&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;"&gt;Lab:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LEFT KEEP(Patient)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;select patient_id, labTest&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;from labTest;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Hope this helps you.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Regards,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Jagan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 01:39:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094499#M363678</guid>
      <dc:creator>jagan</dc:creator>
      <dc:date>2016-01-15T01:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to write load script which uses the same CTE multiple times！！！</title>
      <link>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094500#M363679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use &lt;A href="https://community.qlik.com/docs/DOC-14559"&gt;Variables&lt;/A&gt; to store redundant script- or expression(parts) and in your example might be a for each loop for your sql-loadings possible - but if there are only those few loads and script-lines I wouldn't change it - readability of script is often a more important point then it's short.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 06:43:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-way-to-write-load-script-which-uses-the-same-CTE-multiple/m-p/1094500#M363679</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-01-15T06:43:17Z</dc:date>
    </item>
  </channel>
</rss>

