Also another good practise is to use 3 letters for table aliases. If you could also keep the table aliases the same from SQL to SQL that would be great. I think the patient table is referenced as ptt below.