My apologies about the crappy title, but I am at a complete lost of where to start with this one
I have two tables The first table just has customer ids the second table has a list of interactions we have had with each customer This includes interactions pertaining to appointments as well as a bunch of interaction types, most of which we don't call about
For each customer, we want to the date & description of their last appointment related interaction (whether it is canceled, scheduled, or had) as well as the date of the last prescription refill, if it exists
Table_1
User_ID
-------
001
002
003
Table_2
User_ID Date Interaction
------------------------------------------------------
001 1/21/2015 Canceled Appointment
001 12/09/2014 Scheduled Appointment
001 12/01/2014 Called to Refill Prescription
002 2/1/2015 Had Appointment
002 12/2/2014 Called About Symptoms
002 11/18/2014 Scheduled Appointment
003 2/1/2015 Called to Refill Prescription
003 11/28/2014 Had Appointment
Desired output
User_ID Date Appointment_Details Prescription Refill Date
------------------------------------------------------------------------
001 1/21/2015 Canceled Appointment 12/01/2014
002 2/1/2015 Had Appointment n/a
003 11/28/2014 Had Appointment 2/1/2015
See Question&Answers more detail:os