SELECT *
FROM BPS_Patients
WHERE StatusText = 'Active'
AND DOB < DateAdd(Year, -75, GetDate()) -- put '--' in front of this line to remove age from search
AND NOT EXISTS (
       SELECT EPCREPORTS.INTERNALID , COUNT(*)
       FROM EPCREPORTS
       WHERE EPCREPORTS.RECORDSTATUS = 1
       AND EPCREPORTS.INTERNALID = BPS_Patients.InternalID
       AND REPORTTYPE = 2                                    -- GPMP review
       AND REPORTDATE >= DATEADD(MONTH, -12, GETDATE())      -- Last 12 months
       GROUP BY EPCREPORTS.INTERNALID HAVING COUNT(*) >= 1   -- Having 1 or more visits
)
ORDER BY SURNAME,FIRSTNAME

-- Patients over 75 who haven't had care plan (GPMP) in last 12 months