Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikuser22
Creator II
Creator II

Get Latest data with three fields and using SQL query.

Hi

I have to obtain latest data using sql query. I have loaded the data using HIVE connector. It has three field year,month,date. I want to find max(year),max(month),max(date) and output the latest partition data. 

Example:

Table1:

Load 

..

..

..

year, 

month,

date;

Temp: 

Load max(year) as maxyear,

max(month) as maxmonth,

max(date) as maxdate;

resident table1;

drop table table1;

SQL select * from HIVE.tablename;

 

I want to get the latest partition every time. I am not sure how to use the SQL statement and not sure if I am doing the right thing in load statement. I am very much new to qliksense. 

Thanks in advance. 

Labels (3)
1 Reply
qlikuser22
Creator II
Creator II
Author

I have also modified the script like, 

Table1:

Load 

..

..

..

year, 

month,

date;

SQL SELECT * FROM HIVE.``.`` ;

Temp: 

Load max(year) as maxyear,

max(month) as maxmonth,

max(date) as maxdate;

resident table1;

Let Maxyear = peek('Maxyear',-1);
Let Maxmonth = peek('Maxmonth',-1);
Let Maxday = peek('Maxday',-1);
SQL SELECT * FROM HIVE.``.``
where ( year > $(Maxyear) AND  month > $(Maxmonth) AND day > $(Maxday) );

I don't know if i am right. I get an error. Please help.