How can I use a sub query for just the invite table? I'd like all records from patient_profiles and for the invites join to use only records created after a specific date?
SELECT p.first_name,
COUNT(invites.invited_by_id)as invite_count
FROM patient_profiles AS p
LEFT OUTER JOIN patient_profiles AS invites ON invites.invited_by_id = p.id
WHERE p.is_test = false AND AND invites.created_at >= '2017-10-16'::date
GROUP BY p.first_name