Hi have a table tblCompanyFollowUps which contains the following fields
fldFollowUpID - Primary Key
fldCompanyID
fldFollowUpName
fldFollowUpDate
fldNoMoreFollowUps
fldNotes
Basically the table tracks followups for organisations we provide services to.
A company can have many follow up records.
What im trying to do is set up 2 queries.
The first is to select the record for the next followup date for each company.
eg say I have the following records
fldFollowUpID fldCompanyID fldFollowUpName fldFollowUpDate fldNoMoreFollowUps fldNotes
1 333 Manual 1/1/04 False Test Notes
2 333 test Name 1/2/04 false testnotes
3 333 testname2 2/4/04 false morenotes
4 333 testname3 23/9/04 true notes
5 222 testname 4/5/04 false notes
6 222 test 4/6/04 true testnotes
say todays date is 20/3/04
i would like the query to return
3 333 testname2 2/4/04 false morenotes
5 222 testname 4/5/04 false notes
these are the next followups to occur for each organisation after todays date.
I also need a query to show the last time we were in contact with each organisation, basically
show the highest date value which is less than todays date.
eg with the sample data provided and todays date being 20/3/04 the query would return
2 333 test Name 1/2/04 false testnotes
this is the last time we conducted a follow up for company 333
no record would be returned for company 222 as they didn't have a follow up before 20/3/04
I have had a play around with grouping and selecting the max date, but cant seem to get either query working correctly.
Any help with creating these two queries would be greatly appreciated.
Thanks
Justin
fldFollowUpID - Primary Key
fldCompanyID
fldFollowUpName
fldFollowUpDate
fldNoMoreFollowUps
fldNotes
Basically the table tracks followups for organisations we provide services to.
A company can have many follow up records.
What im trying to do is set up 2 queries.
The first is to select the record for the next followup date for each company.
eg say I have the following records
fldFollowUpID fldCompanyID fldFollowUpName fldFollowUpDate fldNoMoreFollowUps fldNotes
1 333 Manual 1/1/04 False Test Notes
2 333 test Name 1/2/04 false testnotes
3 333 testname2 2/4/04 false morenotes
4 333 testname3 23/9/04 true notes
5 222 testname 4/5/04 false notes
6 222 test 4/6/04 true testnotes
say todays date is 20/3/04
i would like the query to return
3 333 testname2 2/4/04 false morenotes
5 222 testname 4/5/04 false notes
these are the next followups to occur for each organisation after todays date.
I also need a query to show the last time we were in contact with each organisation, basically
show the highest date value which is less than todays date.
eg with the sample data provided and todays date being 20/3/04 the query would return
2 333 test Name 1/2/04 false testnotes
this is the last time we conducted a follow up for company 333
no record would be returned for company 222 as they didn't have a follow up before 20/3/04
I have had a play around with grouping and selecting the max date, but cant seem to get either query working correctly.
Any help with creating these two queries would be greatly appreciated.
Thanks
Justin