I've run into quite a tough problem for my novice SQL query writing skills. I'll try and describe my problem as best I can.
Table1: Account, Date, Time, Area, ResultValue, ResultString, Phone, GUID
Table2: Name, Account, phone, GUID
For each record in Table2 I need the the single record from Table1 that is most accurate to the following criteria: Lowest ResultValue then latest time.
The final result needs to show the most appropriate result and the total # of results based on the phone number.
Final results: Name, Account, phone, Date, Time, ResultString, Attempts
I've done all this but with a painfully slow process of about 9 queries. I can't help but think there is a better way.