I have to transform SQL code into Python using the Pandasql library. I am confused about how this query is working and how the result of each JOIN is used in the next JOIN as well as in the WHERE clause. I want to understand how to break this query line by line so that it will be easy to write this in Python.
Create Table EligiblePeople as
Select distinct UPPER(a.User_ID) as MUDID, a.Entity_ID as Item_ID
From Userlearning as a
Inner Join Reporting as b on (UPPER(a.User_ID)=UPPER(b.MUDID))
Left Join ExcludeTraining as c on (a.Entity_ID=c.Item_ID))
Left Join ExcludeExceptions as d on (UPPER(a.User_ID)=UPPER(d.MUDID) and a.Entity_ID=d.Item_ID)
Left Join ExcludeTrainingAll as e on (a.Entity_ID=e.Item_ID)
Left Join ExcludeMUDID as f on (UPPER(a.User_ID)=UPPER(f.MUDID))
Where a.Assignment_Type='REQUIRED'
and (Not(a.Entity_ID=e.Item_ID) and Not (UPPER(a.User_ID)=UPPER(f.MUDID))
and Not (a.Entity_ID=c.Item_ID and b.VET1=c.Platform)
and Not (UPPER(a.User_ID)=UPPER(d.MUDID) and b.VET1=d.Platform and a.Entity_ID=d.Item_ID)
)