I have to create a query that will look at patients with appointments. I need to see if these are new patients which is defined as any patient not seen in the past three years. The patient will have an appointment that will fall within a date range parameter so I would need to look at the previous appointment date to see if it was within three years of the current appointment date. The table has a patient ID, and ID identifying the appointment, and the appointment date. I was thinking of creating a temp table of all appointments and using it to compare to the list of appointments that fall within the date range parameter. I was wondering what would be the best way to do this?