Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a Patients table and Clinique Visits table.
Not all patients have visits records.
I’d like to add a flag to the Patients table
That represents when no visits exists for the relevant patients.
The following left join doesn’t work.
Left Join (Patients)
LOAD
PatientID,
'No' as WithClnVisits
Resident [Clinique Visits]
Where not Exists (PatientID);
Any idea why?
Thanks!
Try like this:
Visits:
LOAD
PatientID as PatientVisitID
Resident [Clinique Visits];
Patients:
LOAD
PatientID,
if(exists(PatientVisitID, PatientID),'Yes','No') as WithClnVisits,
...
FROM PatientsTable.;
Drop table Visits;
Try like this:
Visits:
LOAD
PatientID as PatientVisitID
Resident [Clinique Visits];
Patients:
LOAD
PatientID,
if(exists(PatientVisitID, PatientID),'Yes','No') as WithClnVisits,
...
FROM PatientsTable.;
Drop table Visits;
You need to do an inner Join with the clinic visits first, and add a flag 'Yes'. Then concatenate the Resident PatientID table with Where not exists condition.
Hi,
Thanks a lot!
Never saw this syntax before 🙂
I managed to achieve the desied result with using the condition in a left join:
Left Join (Patients)
LOAD
PatientID,
if(exists(QlnPatientID, PatientID),'Yes','No') as WithClnVisits
Resident Patients;