We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Boy, I learned a lot doing this. Here is my mySQL code, with comments and similar, but not identical to other posts:
/* these are the columns we want to output */selectc.hacker_id,h.name,count(c.hacker_id)asc_count/* this is the join we want to output them from */fromHackersashinnerjoinChallengesasconc.hacker_id=h.hacker_id/* after they have been grouped by hacker */groupbyc.hacker_id/* but we want to be selective about which hackers we output *//* having is required (instead of where) for filtering on groups */having/* output anyone with a count that is equal to... */c_count=/* the max count that anyone has */(SELECTMAX(temp1.cnt)from(SELECTCOUNT(hacker_id)ascntfromChallengesgroupbyhacker_idorderbyhacker_id)temp1)/* or anyone who's count is in... */orc_countin/* the set of counts... */(selectt.cntfrom(selectcount(*)ascntfromchallengesgroupbyhacker_id)t/* who's group of counts... */groupbyt.cnt/* has only one element */havingcount(t.cnt)=1)/* finally, the order the rows should be output */orderbyc_countDESC,c.hacker_id/* ;) */;
Challenges
You are viewing a single comment's thread. Return to all comments →
Boy, I learned a lot doing this. Here is my mySQL code, with comments and similar, but not identical to other posts: