Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
yelin_nyu
Creator
Creator

load data with latest date

Hi,

it's kind of a miss or hit thing. sometimes it works and other times it doesn't.

I need to find values with latest date. I usually use this method, but it's too long. Any good suggestion to make my life easier? thanks

P;

sql select distinct load_date from tbl1;

P2:

load max(load_date) as MaxDate

resident P;

let vMaxD = peek('MaxDate', 0, 'P')

drop table P;

drop table P2;

Rtble:

sql select * from tbl1

where load_date ='$(vMaxD)';

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

P:

sql select Max(load_date) from tbl1;

let vMaxD = peek('MaxDate', 0, 'P')

drop table P;

Rtble:

sql select * from tbl1

where load_date ='$(vMaxD)';

Hope this helps you.

Regards,

Jagan.

View solution in original post

3 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

P:

sql select Max(load_date) from tbl1;

let vMaxD = peek('MaxDate', 0, 'P')

drop table P;

Rtble:

sql select * from tbl1

where load_date ='$(vMaxD)';

Hope this helps you.

Regards,

Jagan.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Maybe just move the Max() into the first SQL statement?

P:

Load

   load_date

;

sql select max(load_date) from tbl1;

let vMaxD = peek('load_date')

drop table P2;

 

Rtble:

sql select * from tbl1

where load_date ='$(vMaxD)';

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Oops - not sure why I didn't see Jagan's answer there already!