Advertisement
NonplayerCharacter

PostgreSQL | StrataScratch.com | Friend request acceptance rate by date

Apr 23rd, 2022
1,857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- https://platform.stratascratch.com/coding/10285-acceptance-rate-by-date
  2.  
  3. with sent as (
  4.     select
  5.         date as datesent,
  6.         user_id_sender||user_id_receiver as requestid
  7.     from fb_friend_requests
  8.     where action='sent'
  9.     order by 1 asc),
  10.  
  11. accepted as (
  12.     select
  13.         date as dateaccepted,
  14.         user_id_sender||user_id_receiver as requestid
  15.     from fb_friend_requests
  16.     where action='accepted'
  17.     order by 1 asc
  18. )
  19.  
  20. select datesent as date,
  21.         count(dateaccepted)::FLOAT / count(datesent)::FLOAT as percentage_acceptance
  22. from sent s
  23. left join accepted a
  24. on s.requestid = a.requestid
  25. group by 1
  26. order by 1 asc
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement