Skip to content

Instantly share code, notes, and snippets.

@shannah
Created June 25, 2014 22:21
Show Gist options
  • Save shannah/0149380f4ff5615589ca to your computer and use it in GitHub Desktop.
Save shannah/0149380f4ff5615589ca to your computer and use it in GitHub Desktop.
__sql__ = "select c.*,
cc.num_calls,
(select call_result from calls where contact_id=c.contact_id order by time_of_call desc limit 1) as last_call_result,
(select max(time_of_call) from calls where contact_id=c.contact_id) as last_call_time,
(select student_decision from calls where contact_id=c.contact_id order by time_of_call desc limit 1) as last_student_decision,
(select mentor_preference_id from calls where contact_id=c.contact_id order by time_of_call desc limit 1) as last_mentor_pref,
(select group_concat(caller_comments) from calls where contact_id=c.contact_id) as combined_caller_comments
from current_call_list c
left join call_counts cc on cc.contact_id=c.contact_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment