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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Max Date statement on Where clause

Hi,

In Qv load script, how can we write the following statement with the clause to get the Max Date like the example below:

SELECT *

FROM Table1  INNER JOIN Table2  ON  Table1.id = Table2.Id

WHERE Table1.Date  = (select max(T1.Date)

                                               from Table1 T1

                                           where Table1.id = T1.id)

Someone could advice a way to achieve this?

Many thanks

Paulo

4 Replies
maheshkuttappa
Creator II
Creator II

try this

SELECT *

FROM Table1 A ,

Table2 B

(select max(T1.Date) from

Table1 T1) C

Where A.id=B.Id

And A.id=C.id 

Not applicable
Author

Table1:

load max(Date) as Date,

          id

from ... group by id;


//table2

inner join (Table1)

load *

from ...

         


sunny_talwar

May be this:

Table:

LOAD Id,

          Date

From ....

Inner Join (Table)

LOAD Id,

     Max(Date) as Date

Resident Table

Group By Id;

vishsaggi
Champion III
Champion III

Kind of a work around, let me know if this works ?

Table1:

SELECT *

FROM Table1  INNER JOIN Table2  ON  Table1.id = Table2.Id;

Temp:

LOAD max(Date1) AS MaxDate

Resident Table1;

LET vMaxDate = Date(Peek('MaxDate',0, 'Temp'), 'MM/DD/YYYY');

Drop Table Temp;

Final:

Load *

Resident Table1

Where Date = $(vMaxDate);