Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
sergio0592
Valued Contributor II

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

Tags (1)
1 Solution

Accepted Solutions
Highlighted

Re: Use variable in SQL statement

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
Highlighted

Re: Use variable in SQL statement

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

Highlighted
sergio0592
Valued Contributor II

Re: Use variable in SQL statement

Thanks it works