<?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 How to use Query Result From One Query in Another? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309924#M1198589</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest storing the Ticket_ID's from your first query in a variable, you would use the Concat() function to create a comma separated list and then pass the variable in your sql using syntax something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tickets:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Concat(Chr(39) &amp;amp; Ticket_ID &amp;amp; Chr(39),', ') as Tickets;&lt;/P&gt;&lt;P&gt;Select Ticket_ID from...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let YourVar = Peek('Tickets',0,'Tickets');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from Blah where Ticket_ID In ($(YourVar));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 May 2011 17:49:11 GMT</pubDate>
    <dc:creator>chriscammers</dc:creator>
    <dc:date>2011-05-18T17:49:11Z</dc:date>
    <item>
      <title>How to use Query Result From One Query in Another?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309923#M1198588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Suppose I have a Query Say "Select Ticket_ID, Status from Table A". It returns Ticket_ID values as 1, 2, 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Now I want to use the values in Another query without writing a sub query&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Query Should be Select ticket_ID, Sum(Value) from Table B Where Ticket_ID in (1, 2, 3) i.e.values from Query 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;And Not Select Ticket_ID, sum(Value) from Table A Where Ticket_ID in (Select Ticket_ID from table A)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Because the actual Query I have Is quite big and I dont want to use that as a subquery.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I cannot used join here since it with give me 1 -&amp;gt; n values which will give incorrect results.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Please suggest&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Suresh&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 17:17:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309923#M1198588</guid>
      <dc:creator />
      <dc:date>2011-05-18T17:17:48Z</dc:date>
    </item>
    <item>
      <title>How to use Query Result From One Query in Another?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309924#M1198589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest storing the Ticket_ID's from your first query in a variable, you would use the Concat() function to create a comma separated list and then pass the variable in your sql using syntax something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tickets:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Concat(Chr(39) &amp;amp; Ticket_ID &amp;amp; Chr(39),', ') as Tickets;&lt;/P&gt;&lt;P&gt;Select Ticket_ID from...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let YourVar = Peek('Tickets',0,'Tickets');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from Blah where Ticket_ID In ($(YourVar));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 17:49:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309924#M1198589</guid>
      <dc:creator>chriscammers</dc:creator>
      <dc:date>2011-05-18T17:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Query Result From One Query in Another?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309925#M1198590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Test:&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;Ticket_ID,&lt;/P&gt;&lt;P&gt;Status &lt;/P&gt;&lt;P&gt;from TableA.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;ticket_ID as Ticket_ID,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // I assume that ticket_ID is another field in table B &lt;/P&gt;&lt;P&gt;Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //which has same values as Ticket_ID from table A&lt;/P&gt;&lt;P&gt;from TableB.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Test1:&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;Ticket_ID, &lt;/P&gt;&lt;P&gt;Value &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resident Test where Ticket_ID=1 or&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;Ticket_ID=2 or Ticket_ID=3;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table Test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Test2:&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;Ticket_ID, &lt;/P&gt;&lt;P&gt;Sum(Value) as Total_Value&lt;/P&gt;&lt;P&gt;resident Test1 group by&amp;nbsp; Ticket_ID;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table Test1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2011 09:06:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309925#M1198590</guid>
      <dc:creator />
      <dc:date>2011-05-20T09:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Query Result From One Query in Another?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309926#M1198591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;TB_A&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: blue; font-size: 9pt;"&gt;SELECT&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TICKET_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STATUS&lt;BR /&gt;FROM TABLE_A;&lt;BR /&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: blue; font-size: 9pt;"&gt;INNER&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: blue; font-size: 9pt;"&gt;JOIN&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: blue; font-size: 9pt;"&gt;SELECT&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: 'Courier New'; color: black; font-size: 9pt;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TICKET_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM(VALUE) AS TICKET_VALUE&lt;BR /&gt;FROM TABLE_B&lt;BR /&gt;GROUP BY TICKET_ID; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2011 16:24:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Query-Result-From-One-Query-in-Another/m-p/309926#M1198591</guid>
      <dc:creator />
      <dc:date>2011-05-20T16:24:32Z</dc:date>
    </item>
  </channel>
</rss>

