Hi all,
I'm currently running this query
That produces all of the records with a dateCreated in the table callHistory. I should clarify for each attempt that is made to call a contact there is one record for it in the callHistory. So one contact can have many callhistoryRecords.
The query above gives me all with the earliest dateCreated, which is what I set out to do. Now I need it to give me that result set plus any record that does not yet have a callHistory dateCreated value.
I have to run this once a day to match against a file provided to us from the client.
Twist
===========================================
Everything will be OK in the end.
If it's not OK, then it's not the end
I'm currently running this query
Code:
select c.contactID, c.companyID, c.companyName, c.prefix, c. firstName, c. middleName, c.lastName, c.suffix,c.jobTitle, c.phy_address1, c.phy_address2, c.phy_address3, c.phy_city, c.phy_state, c.phy_zipCode, c.phy_country, c. mlg_address1, c.phone, c.referralID, c.statusId, cf.KEYCODE, ch.datecreated, ch.userid
from contacts c
inner join clientfields cf on c.contactID = cf.contactID
left join callHistory ch on c.contactID = ch.contactID
HAVING (ch.dateCreated =
(SELECT DISTINCT MIN( ch.dateCreated) FROM callHistory ch WHERE ch.contactID = c.contactID))
That produces all of the records with a dateCreated in the table callHistory. I should clarify for each attempt that is made to call a contact there is one record for it in the callHistory. So one contact can have many callhistoryRecords.
The query above gives me all with the earliest dateCreated, which is what I set out to do. Now I need it to give me that result set plus any record that does not yet have a callHistory dateCreated value.
I have to run this once a day to match against a file provided to us from the client.
Twist
===========================================
Everything will be OK in the end.
If it's not OK, then it's not the end