List of users who signed up via invitations

My SQL skills are still a little fledgling, but try this one and see if I’ve got the look-ups working properly: :slight_smile:

SELECT u1.username AS invitee, 
       u2.username AS inviter,
       iu.redeemed_at
FROM invited_users iu
JOIN invites i ON iu.invite_id = i.id
JOIN users u1 ON iu.user_id = u1.id
JOIN users u2 ON i.invited_by_id = u2.id
WHERE iu.redeemed_at IS NOT NULL
ORDER BY iu.redeemed_at DESC
5 Likes