File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -569,6 +569,7 @@ Your ideas/fixes/algorithms are more than welcome!
569
569
| 612| [ Shortest Distance in a Plane] ( https://leetcode.com/problems/shortest-distance-in-a-plane/ ) | [ Solution] ( ../master/database/_612.sql ) | || Medium|
570
570
| 610| [ Triangle Judgement] ( https://leetcode.com/problems/triangle-judgement/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_610.java ) | | | Easy |
571
571
| 607| [ Sales Person] ( https://leetcode.com/problems/sales-person/ ) | [ Solution] ( ../master/database/_607.sql ) | | | Easy |
572
+ | 597| [ Friend Requests I: Overall Acceptance Rate] ( https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate/ ) | [ Solution] ( ../master/database/_597.sql ) | | | Easy |
572
573
| 596| [ Classes More Than 5 Students] ( https://leetcode.com/problems/classes-more-than-5-students/ ) | [ Solution] ( ../master/database/_596.sql ) | || Easy |
573
574
| 595| [ Big Countries] ( https://leetcode.com/problems/big-countries/ ) | [ Solution] ( ../master/database/_595.sql ) | O(n) | O(1) | Easy |
574
575
| 586| [ Customer Placing the Largest Number of Orders] ( https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/ ) | [ Solution] ( ../master/database/_586.sql ) | | | Easy|
Original file line number Diff line number Diff line change
1
+ -- 597. Friend Requests I: Overall Acceptance Rate
2
+
3
+ select
4
+ round(
5
+ ifnull(
6
+ (select count (distinct requester_id,accepter_id) from request_accepted)
7
+ /
8
+ (select count (distinct sender_id, send_to_id) from friend_request)
9
+ ,0 )
10
+ ,2 )
11
+ as accept_rate;
12
+
13
+ -- The divisor (total number of requests) could be '0'
14
+ -- if the table friend_request is empty.
15
+ -- So, we have to utilize ifnull to deal with this special case.
You can’t perform that action at this time.
0 commit comments