Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
johnan
Creator III
Creator III

Variable to SQL

Hi Community, getting crazy. This have worked earlier.

Got this first to get the highest nuber from a time field in database:

Load
NUM(MAXTID) as MAXTID;
SELECT max(R2PTIM) as MAXTID from TABLE where R2CMP = '222' and R2PDAT >= current_date;
LET VLastUp = MAXTID;

Load
NUM(MAXTID) as MAXTID;
SELECT max(R2PTIM) as MAXTID from CLICFILPRD.RKNRP200 where R2CMP = '222' and R2PDAT >= current_date;
LET VLastUp = MAXTID; in variable

Then i want to use this VLastUp in the next SQL in script:

SELECT * from Table where R2CMP = '222' and R2PDAT >= current_date and R2PTIM > '$(VLastUp)';

Just want to store the highest time in Variable, then nest reolad, just show me the post with higher time than the last time and so on

Br

John

Can't get this to work.

R2PTIM is time in DB i think, like this 105 811

1 Reply
Miguel_Angel_Baeyens

The syntax you posted is correct and it should work, provided VLastUp and R2PTIM have the same format, else the condition will never be met and the results returned would not be the expected ones.

Make sure VLastUp displays its value with the same format than R2PTIM. You can use TRACE '$(VLastUp)'; in your script to see the format it takes when the script runs and troubleshoot.