
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
where clause
Hello all,
i am new to QLIK Sense developing and looking for help.
how do i code in Qlik Sence the following simple SQL query :
SELECT * FROM Table1
WHERE date = (SELECT MAX(date) FROM Table1)
i tried to do it with variable, something like this
set param1 = (SELECT MAX(date) FROM Table1)
Table2:
load *
resident Table1
where date = $'param1'
but that don't work.
please help
Thanks in advance
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My suggestion was aimed to assign a string to a variable. But now I have the impression that you want to execute a query and assign the query-result to the variable - that's not possible. To get this you need to something like the following:
t: sql select max(date) as t from table;
set param1 = peek('t', 0, 't');
Depending on the target-query you may also need some formatting with date() and setting the variable-call within quotes like: '$(param1)'.
- Marcus


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try it with:
... where date = $(param1) ...
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI,
that didn't work. i think this line does not work:
set param1 = (SELECT MAX(date) resident Table1)
when i execute in debug mode i do not see the param1 result in the output section.
is it even possible to set a variable from a query ? or is it just a syntax issue ?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My suggestion was aimed to assign a string to a variable. But now I have the impression that you want to execute a query and assign the query-result to the variable - that's not possible. To get this you need to something like the following:
t: sql select max(date) as t from table;
set param1 = peek('t', 0, 't');
Depending on the target-query you may also need some formatting with date() and setting the variable-call within quotes like: '$(param1)'.
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the solution !
