one possible answer for question 2 cumulative sums by day.

  • 1
    ifnull(round(sum(case when t.ind = 'a' then t.cnt else 0 end)/sum(case when t.ind = 'r' then t.cnt else 0 end),2),0) as accept_rate
    (select distinct x.request_date as date from friend_request as x 
     select distinct y.accept_date as date from request_accepted as y 
    ) as s 
    left join 
    (select v.request_date as date, count(*) as cnt,'r' as ind from friend_request as v group by v.request_date
    union all
     select w.accept_date as date, count(*) as cnt,'a' as ind from request_accepted as w group by w.accept_date
    ) as t 
    on >= 
    group by

Log in to reply

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