M
marion
I support online learners and in this particular query I
am using two tables one for the student information and
one containing all the contact I have had with the
student.
I am trying to write a query to return students that I
have not had any contact with for 28 days.
I have tried <Date()-28 in the Feedback date field but
this looks at any date in the record not the most recent
date out of the list. I have also tried the Top 1
statement as suggestion in a previous answer, but it is
not returning the correct information.
How can I set the query parameters to look at the newest
date in the list? I attach my SQL in case this will help
SELECT TOP 1 Students.StudentID AS Students_StudentID,
Students.DateAllocated, Students.StudentChristianName,
Students.StudentSurname, Students.StudentemailAddress,
Students.WelcomeLetter, Students.InductionFeedback,
Students.[Advice & Guidance], Students.ILP,
Students.Status, Students.CollegeID, Students.CourseID,
Students.InductionID, Feedback.FeedbackID, Feedback.Date,
Feedback.Time, Feedback.ContactCategory,
Feedback.ContactTime, Feedback.NonTeachingTime,
Feedback.TypeofContact, Feedback.TypeOfFeedback,
Feedback.Activity, Feedback.ID, Feedback.Situation,
Feedback.Reference, Feedback.NextMove, Feedback.StudentID
AS Feedback_StudentID
FROM Students INNER JOIN Feedback ON Students.StudentID =
Feedback.StudentID
WHERE (((Students.Status)="Active") AND ((Feedback.Date)
<Date()-28))
ORDER BY Feedback.Date DESC;
Any suggestions gratefully recieved
Many thanks
Marion
am using two tables one for the student information and
one containing all the contact I have had with the
student.
I am trying to write a query to return students that I
have not had any contact with for 28 days.
I have tried <Date()-28 in the Feedback date field but
this looks at any date in the record not the most recent
date out of the list. I have also tried the Top 1
statement as suggestion in a previous answer, but it is
not returning the correct information.
How can I set the query parameters to look at the newest
date in the list? I attach my SQL in case this will help
SELECT TOP 1 Students.StudentID AS Students_StudentID,
Students.DateAllocated, Students.StudentChristianName,
Students.StudentSurname, Students.StudentemailAddress,
Students.WelcomeLetter, Students.InductionFeedback,
Students.[Advice & Guidance], Students.ILP,
Students.Status, Students.CollegeID, Students.CourseID,
Students.InductionID, Feedback.FeedbackID, Feedback.Date,
Feedback.Time, Feedback.ContactCategory,
Feedback.ContactTime, Feedback.NonTeachingTime,
Feedback.TypeofContact, Feedback.TypeOfFeedback,
Feedback.Activity, Feedback.ID, Feedback.Situation,
Feedback.Reference, Feedback.NextMove, Feedback.StudentID
AS Feedback_StudentID
FROM Students INNER JOIN Feedback ON Students.StudentID =
Feedback.StudentID
WHERE (((Students.Status)="Active") AND ((Feedback.Date)
<Date()-28))
ORDER BY Feedback.Date DESC;
Any suggestions gratefully recieved
Many thanks
Marion