Query to Determine Most Recent Phone Number Used
Posted on 2016-07-20
I have a requirement to retrieve the most recent phone number used in contacting each property.
The fields in table ‘tblProperty_CallResults’ which is a log of all call results
ID autonumber, primary key
PropertyID Number, many calls may be logged for the same Property
PhoneNum Number, Long
CallResultID Number, Long
DateOfCall Date/Time, format short date
TImeOfCall Date/Time, format short time
CallerTypeID Number, Long
The result set will contain only two fields
The result set will only contain 1 record for each propertyID. The PhoneNum on that record will be the PhoneNum from the most recent call. The most recent call is the one with the most recent ‘TimeOFCall’ on the most recent ‘DateOfCall’.
In creating the result set:
Only Include records where the ‘CallResultID’ = 4 or 5
Only Include records where the ‘CallerTypeID= 1 Or 2 Or 9 Or 8 Or 6 Or 16
I'm having a mental block on this one.