Chapter 4 Exercise 54

54. List the female patients who do not use tobacco and were between 50 and 55 at the time of the visit. Hint: Use the DateDiff function to compute the age.

SELECT Patient.PatientID, Patient.Gender, Visit.VisitDate, Patient.TobaccoUse,
DateDiff("yyyy",[DateofBirth],[VisitDate]) AS VisitAge
FROM Patient INNER JOIN Visit ON Patient.PatientID = Visit.PatientID
WHERE (((Patient.Gender)="Female")
AND ((Patient.TobaccoUse)=False) AND ((DateDiff(“yyyy”,[DateofBirth],[VisitDate])) Between 50 And 55));