Qlik Community

Ask a Question

New to QlikView

If you’re new to QlikView, start with this Discussion Board and get up-to-speed quickly.

Announcements
Welcome to our newly redesigned Qlik Community! Read our blog to learn about all the new updates: READ BLOG and REPORTED ISSUES
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

SQL script in qlikview

Hi All,

I am new to qlikview please help me to implement below script in qlikview.

SELECT t.P_id, t.C_id, t.C_date, t.C_score
FROM temp t
INNER JOIN (SELECT P_id, C_id, Max(C_date) AS mdate, C_score
FROM temp
WHERE C_date >= "2018-11-17" and C_date <= "2018-11-20"
GROUP BY P_id) AS a
ON a.P_id = t.P_id AND a.mdate = t.C_date 

Labels (3)
1 Reply
Luminary
Luminary

Assuming that the SQL query you listed works, use the following

Load
     P_id,
     C_id,
     C_date,
     C_score;
SQL SELECT t.P_id, t.C_id, t.C_date, t.C_score

FROM temp t
INNER JOIN (SELECT P_id, C_id, Max(C_date) AS mdate, C_score
FROM temp
WHERE C_date >= "2018-11-17" and C_date <= "2018-11-20"
GROUP BY P_id) AS a
ON a.P_id = t.P_id AND a.mdate = t.C_date ;


If you want to change any field names in your Qlik model then use "as" (I made up an example below).

Load
     P_id as [Person ID],

... etc.

Don't forget the ";" after the load statement and the SQL statement, or you'll get an error. Note that your "Select" statement is now receded by the word "SQL".

 

Enjoy.