I have two tables (see screenshot below)
1. Encounters - List all appt encounters including the date of the encounter and flags indicating if the encounter is a New Patient, Seen in 10 Business Days, etc.
2. Dates - list of dates including flags to show whether or not the date occurs this month.
I would like to count encounters where New_Patient_Visit = 1 and where Date of Encounter is Equal to a Calendar_DT in the Dates table where Current Month Flag = 1
In SQL it would look like this
SELECT COUNT(E.NEW_PATIENT_VISIT)
FROM ENCOUNTERS E
INNER JOIN DATES D ON E.ENC_DATE = D.CALENDAR_DT
WHERE E.NEW_PATIENT_VISIT = 1 AND D.[Current Month Flag] = 1
Thanks in advance!