题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
--解决方案(1) selectactivityfromFriendsgroupbyactivityhavingcount(id) != (selectcount(id) fromFriendsgroupbyactivityorderbycount(id) desclimit1) andcount(id) != (selectcount(id) fromFriendsgroupbyactivityorderbycount(id) limit1) --解决方案(2) WITHt1AS(SELECTactivity, COUNT(*) cntFROMFriendsGROUPBYactivity), t2AS(SELECTactivity, DENSE_RANK() OVER(ORDERBYcnt) rkFROMt1), t3AS(SELECTMAX(rk) maxnFROMt2) SELECTnameactivityFROMActivitiesWHEREnameIN (SELECTactivityFROMt2WHERErk>1ANDrk< (SELECT*FROMt3))