My solution using Coalesce and CROSS Joined subqueries

  • 0
    SELECT COALESCE(ROUND(SUM(t1.total_accepted) / SUM(t2.total_requested), 2), 0) AS accept_rate
    FROM (
        SELECT COUNT(DISTINCT requester_id, accepter_id) AS total_accepted
        FROM request_accepted
    ) t1 CROSS JOIN (
        SELECT COUNT(DISTINCT sender_id, send_to_id) AS total_requested
        FROM friend_request
    ) t2

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.