RickLV
03-19-2007, 06:14 PM
I'm trying to display a list of scheduled appointments, but with my query I cannot eliminate the any duplicates
In case of more than one contact (record) for the same sales lead I'd like to display only the most recent one. So in my example, record 1 and 2 belong to the same sales lead. Technically my agent has already contacted the customer on 03/10/07 so the first line (record) should not be displayed
23-23-03/03/07-community01-first-last-03/03/07-email-03/10/07-11:00
23-25-03/03/07-community01-first-last-03/10/07-email-03/19/07-12:00
01-24-03/12/07-community02-first-last-03/12/07-email-03/21/07-15:00
...
Any idea?
Thanks
rick
SELECT tblContacts.intLeadID, tblContacts.intContactID, tblLeads.dteLeadDateIn, tblCommunities.txtCommunityName, tblLeads.txtLeadFirst, tblLeads.txtLeadLast, tblContacts.dteLastContact, tblContacts.txtMethod, tblContacts.txtContactedBy, tblContacts.memContactComments, tblContacts.dteNextContactDate, tblContacts.dteNextContactTime, tblLeads.intStatusID
FROM (tblCommunities INNER JOIN tblLeads ON tblCommunities.intCommunityID = tblLeads.intCommunityID) INNER JOIN tblContacts ON tblLeads.intLeadID = tblContacts.intLeadID
WHERE (((tblContacts.dteNextContactDate) Is Not Null))
ORDER BY tblContacts.dteNextContactDate;
In case of more than one contact (record) for the same sales lead I'd like to display only the most recent one. So in my example, record 1 and 2 belong to the same sales lead. Technically my agent has already contacted the customer on 03/10/07 so the first line (record) should not be displayed
23-23-03/03/07-community01-first-last-03/03/07-email-03/10/07-11:00
23-25-03/03/07-community01-first-last-03/10/07-email-03/19/07-12:00
01-24-03/12/07-community02-first-last-03/12/07-email-03/21/07-15:00
...
Any idea?
Thanks
rick
SELECT tblContacts.intLeadID, tblContacts.intContactID, tblLeads.dteLeadDateIn, tblCommunities.txtCommunityName, tblLeads.txtLeadFirst, tblLeads.txtLeadLast, tblContacts.dteLastContact, tblContacts.txtMethod, tblContacts.txtContactedBy, tblContacts.memContactComments, tblContacts.dteNextContactDate, tblContacts.dteNextContactTime, tblLeads.intStatusID
FROM (tblCommunities INNER JOIN tblLeads ON tblCommunities.intCommunityID = tblLeads.intCommunityID) INNER JOIN tblContacts ON tblLeads.intLeadID = tblContacts.intLeadID
WHERE (((tblContacts.dteNextContactDate) Is Not Null))
ORDER BY tblContacts.dteNextContactDate;