<?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 Using Variable in SQL statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349524#M129491</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jagan, let me try this one..i think you are right.I will reply after checking this code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 May 2012 10:54:00 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-05-14T10:54:00Z</dc:date>
    <item>
      <title>Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349517#M129484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created&amp;nbsp; a variable called MaxTimeStamp like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MaxTab:&lt;BR /&gt;LOAD&lt;/P&gt;&lt;P&gt;max(timestamp) as MaxStamp&lt;/P&gt;&lt;P&gt;from test.qvd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let MaxStamp = peek('MaxStamp', 0, MaxTable)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when we used this variabale $(MaxStamp) in SQL select statement is not working.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LOAD&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;testcolumn;&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;FROM testtable&lt;/P&gt;&lt;P&gt;where timestamp &amp;gt; $(MaxTimestamp);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Might be there is some problem in syntax or there is a specific way to use variable in SQL select statement.&lt;/P&gt;&lt;P&gt;Waiting for your replies...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR!&lt;/P&gt;&lt;P&gt;Sammm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:12:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349517#M129484</guid>
      <dc:creator />
      <dc:date>2012-05-14T10:12:18Z</dc:date>
    </item>
    <item>
      <title>Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349518#M129485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try not using $(MaxTimestamp) but only &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where timestamp &amp;gt; MaxTimestamp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Giampiero&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:17:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349518#M129485</guid>
      <dc:creator />
      <dc:date>2012-05-14T10:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349519#M129486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;where timestamp &amp;gt; '$(MaxTimestamp)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- But make sure your timeformat should match with sql time format. B'coz to catch max value you are using Max syntax of qlikview, it gives in numer format. So you need to change to timeformat as per sql time stamp. For example if your timeformat of sql is in below format&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2011-06-08 00:10:12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you need to use &lt;STRONG&gt;where timestamp &amp;gt; 'Date($(MaxTimestamp),'YYYY-MM-DD hh:mm:ss')'&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:22:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349519#M129486</guid>
      <dc:creator>jagannalla</dc:creator>
      <dc:date>2012-05-14T10:22:30Z</dc:date>
    </item>
    <item>
      <title>Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349520#M129487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jagan, thanks for reply but its not working, I have tried this already.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:26:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349520#M129487</guid>
      <dc:creator />
      <dc:date>2012-05-14T10:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349521#M129488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;A detail ... unequal LET &amp;amp; WHERE, pls to look image attached&lt;/P&gt;&lt;P&gt;Good luck, Luis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:30:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349521#M129488</guid>
      <dc:creator>llauses243</dc:creator>
      <dc:date>2012-05-14T10:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349522#M129489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;make sure your timeformat should match with sql time format. B'coz to catch max value you are using Max syntax of qlikview, it gives in numer format. So you need to change to timeformat as per sql time stamp. For example if your timeformat of sql is in below format&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2011-06-08 00:10:12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you need to use &lt;STRONG&gt;where timestamp &amp;gt; 'Date($(Maxstamp),'YYYY-MM-DD hh:mm:ss')'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;other wise change here itself&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MaxTab:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;max(timestamp) as MaxStamp&lt;/P&gt;&lt;P&gt;from test.qvd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let MaxStamp = peek('MaxStamp', 0, MaxTable);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vMaxDate=Date('$(MaxStamp)','YYYY-MM-DD hh:mm:ss');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where timestamp &amp;gt; '$(vMaxDate)'&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:32:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349522#M129489</guid>
      <dc:creator>jagannalla</dc:creator>
      <dc:date>2012-05-14T10:32:28Z</dc:date>
    </item>
    <item>
      <title>Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349523#M129490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello Luis, Yes its just a typing mistake when i wrote the question here.but its same on my script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:44:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349523#M129490</guid>
      <dc:creator />
      <dc:date>2012-05-14T10:44:03Z</dc:date>
    </item>
    <item>
      <title>Using Variable in SQL statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349524#M129491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jagan, let me try this one..i think you are right.I will reply after checking this code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:54:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variable-in-SQL-statement/m-p/349524#M129491</guid>
      <dc:creator />
      <dc:date>2012-05-14T10:54:00Z</dc:date>
    </item>
  </channel>
</rss>

