My query does not pass, can anyone provide the correct solution?

  • 0

    select case when count(distinct a.sender_id, a.send_to_id) = 0 then 0.00
    else round(count(distinct a.sender_id, a.send_to_id)/(select COUNT(distinct sender_id, send_to_id) from friend_request), 2) end accept_rate
    from friend_request a
    join request_accepted b
    on a.sender_id = b.requester_id and a.send_to_id = b.accepter_id and a.request_date <= b.accept_date;

    {"headers": ["accept_rate"], "values": [[0.75]]}
    {"headers": ["accept_rate"], "values": [[1.00]]}

    I misunderstand the question? I am still thinking my answer is correct....

  • 0

    This is a easy problem so you just need to count the accepted requests / the total requests. For the above case, there are 4 requests, and there are 4 accepted requests, so the overall acceptance rate is 4/4 = 1.00.

    Sorry for leading your misunderstanding.

Log in to reply

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