-- 查看所有已绑定邀请关系的详细信息
-- 包含：被邀请人ID、被邀请人账号(Email/Identifier)、推荐人ID、推荐人账号、绑定时间
SELECT 
    u.id AS '被邀请人ID (Invitee ID)',
    (SELECT auth_identifier FROM user_auth_methods WHERE user_id = u.id LIMIT 1) AS '被邀请人账号 (Invitee Account)',
    u.referer_id AS '推荐人ID (Referrer ID)',
    (SELECT auth_identifier FROM user_auth_methods WHERE user_id = u.referer_id LIMIT 1) AS '推荐人账号 (Referrer Account)',
    u.created_at AS '注册时间 (Registered At)'
FROM 
    user u
WHERE 
    u.referer_id > 0
ORDER BY 
    u.id DESC;

-- 如果只想看简单的计数统计
-- SELECT referer_id, count(*) as invite_count FROM user WHERE referer_id > 0 GROUP BY referer_id;
