Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Luka1615
Contributor
Contributor

Subqueries - script

Hi everybody,

Can I do this in script?

I do not know how to compare ID in external query to internal ID..

 

SELECT proj_st.id, proj.id,ERP_Primary_Key AS ponumber,NAME AS action_name,users.nick approver_name,proj_st.status,start_date,end_date,real_end,

po_approvals_decisions.decision, parent

FROM proj JOIN proj_st ON proj.id=proj_st.proj_id LEFT JOIN users ON employee_id=users.id

LEFT JOIN po_approvals_decisions ON proj.id=po_approvals_decisions.poid AND proj_st.employee_id=po_approvals_decisions.user

AND DATE(real_end)=DATE(updatetime)

WHERE ERP_Primary_Key='8030742' /*M3 PO*/

AND employee_id>100 /*Without system users*/

and proj_st.id in

/* get only last approver*/

(select max(proj_st2.id) from proj proj2 JOIN proj_st proj_st2 ON proj2.id=proj_st2.proj_id where proj2.id =proj.id and employee_id>100)

and exists

/*get only approved orders*/

(select 1 from proj proj2 JOIN proj_st proj_st2 ON proj2.id=proj_st2.proj_id where proj2.id =proj.id and

employee_id<=100 and proj_st2.parent=33 and proj_st2.status=0 and proj2.id=proj.id)

 

 

Regards,

Luka

1 Reply
Brett_Bleess
Former Employee
Former Employee

@Luka1615 Have a look at the following Design Blog post, believe that may point you in the right direction, but I am not sure, you may need to further clarify things if not:

https://community.qlik.com/t5/Qlik-Design-Blog/Preceding-Load/ba-p/1469534

If you want to search the Design Blog area further, use the following link:

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.