Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sergio0592
Specialist III
Specialist III

Use variable in SQL statement

Hi all,

I have to use variable in SQL. This variable fetch the max Date of a field (DH_START). So, when i perform my SQL query on Oracle, it works.

E.g the max date is 30/06/2018 23:52:00

The part of my SQL query using this is :

WHERE DH_START >= TO_DATE('30/06/2018 23:52:00', 'DD/MM/YYYY HH24:MI:SS')

The target is that the same query works in my Qlikview SQL statement.

But, the following statement don't works:

WHERE DH_START > TO_DATE($(Max_DH_2),'DD/MM/YYYY HH24:MI:SS')

I use :

SET Max_DH=max(DH_START);
SET Max_DH_2=chr(39)&$(Max_DH)&chr(39);

When i use $(Max_DH_2) in a text box, it returns  '30/06/2018 23:52:00'. So, $(Max_DH_2) should works.

What i have missed?

Thanks

1 Solution

Accepted Solutions
sunny_talwar

You cannot use Max() function directly in the variable... you will need to use Max() in a load statement and then peek its value into the variable... just like you would do for a master calendar script

View solution in original post

2 Replies
sunny_talwar

You cannot use Max() function directly in the variable... you will need to use Max() in a load statement and then peek its value into the variable... just like you would do for a master calendar script

sergio0592
Specialist III
Specialist III
Author

Thanks it works