题目链接:点击打开链接
题目大意:略。
解题思路:1/0, 0/0 结果都为 NULL。
AC 代码
--解决方案(1) WITHt1AS(SELECT1id, COUNT(DISTINCTrequester_id, accepter_id) upFROMRequestAccepted), t2AS(SELECT1id, COUNT(DISTINCTsender_id, send_to_id) downFROMFriendRequest) SELECTIF(down=0, 0.00, ROUND(up/down, 2)) accept_rateFROMt1, t2WHEREt1.id=t2.id--解决方案(2) selectround( ifnull( (selectcount(*) from (selectdistinctrequester_id, accepter_idfromrequest_accepted) asA) / (selectcount(*) from (selectdistinctsender_id, send_to_idfromfriend_request) asB), 0) , 2) asaccept_rate;