SELECT DISTINCT p.id ,p.full_name ,p.uuid ,p.email ,c.name AS course_name ,c.uuid as course_uuid ,e.created_at AS enrollment_time ,t.course_completed_at ,t.first_activity_completed_at ,t.last_activity_completed_at ,t.attempt_number ,t.progress FROM people p JOIN enrollments e ON e.learner_id = p.id JOIN courses c ON c.id = e.course_id JOIN schools s ON s.id = p.school_id LEFT JOIN (SELECT DISTINCT p.id AS person ,ca.completed_at AS course_completed_at ,min(com.created_at) AS first_activity_completed_at ,max(com.updated_at) AS last_activity_completed_at ,ca.created_at AS enrollment_time ,ca.attempt_number AS attempt_number ,ca.progress AS progress FROM courses c RIGHT JOIN course_attempts ca ON ca.course_id = c.id JOIN partnerships pa ON pa.id = ca.partnership_id JOIN schools s ON s.id = c.school_id JOIN people p ON p.id = pa.person_id JOIN completions com ON com.course_attempt_id = ca.id AND c.name ='PASS Basic - The Industry Standard' GROUP BY 1,2,5,6,7) t ON t.person = p.id WHERE p.email = 'joelclaiborne@yahoo.com' AND c.name ='PASS Basic - The Industry Standard';