SELECT *
FROM BPS_Patients p
WHERE p.StatusText = 'Active'
AND p.InternalID IN 
	(
	 SELECT a.INTERNALID
	 FROM APPOINTMENTS a
	 INNER JOIN APPOINTMENTTYPES apt ON a.APPOINTMENTTYPE = apt.APPOINTMENTCODE
	 WHERE apt.[DESCRIPTION] LIKE '%Covid 1st Dose%' -- Add your appointment type inbetween the two percentage signs
	 AND a.APPOINTMENTDATE >= GETDATE()
	 AND a.RECORDSTATUS = 1)
	 AND p.DOB > DATEADD(YEAR, -60, GETDATE()
	)
ORDER BY Surname, Firstname;

-- Patients booked for upcoming appointments for appointment type like “COVID 1st Dose” and is under the age of 60 years