{"id":8104,"date":"2024-04-10T14:32:43","date_gmt":"2024-04-10T06:32:43","guid":{"rendered":"https:\/\/white-night.club\/?p=8104"},"modified":"2024-04-10T14:32:43","modified_gmt":"2024-04-10T06:32:43","slug":"ad179","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2024\/04\/10\/ad179\/","title":{"rendered":"574. \u5f53\u9009\u8005"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode.cn\/problems\/winning-candidate\/description\/\">https:\/\/leetcode.cn\/problems\/winning-candidate\/description\/<\/a><\/p>\n\n\n\n<p>\u5f53\u4f60\u7b2c\u4e00\u6b21\u53d1\u73b0\u805a\u5408\u51fd\u6570\u53ef\u4ee5\u5728ORDER BY \u4e2d\u4f7f\u7528\u65f6belike<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"255\" height=\"227\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2024\/03\/67887318ba1538c9172a1106e06516d.jpg\" alt=\"\" class=\"wp-image-7504\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p>\u9898\u672c\u8eab\u8fd8\u662f\u86ee\u7b80\u5355\u7684\uff0c\u53ea\u7528\u6c42\u51fa\u73b0\u6b21\u6570\u6700\u591a\u7684\u8bb0\u5f55\u800c\u5df2\uff0c\u800c\u4e14\u4e0d\u9700\u8981\u8003\u8651\u6709\u4e24\u4e2a\u4ee5\u4e0a\u6700\u5927\u51fa\u73b0\u6b21\u6570\u7684\u60c5\u51b5\u3002\u4e00\u5f00\u59cb\u60f3\u7740\u8bd5\u8bd5\u80fd\u4e0d\u80fd\u5728ORDER BY\u91cc\u5934\u76f4\u63a5\u7528COUNT\u6765\u5077\u4e2a\u61d2\uff0c\u8fd8\u4ee5\u4e3a\u4f1a\u62a5\u9519\uff0c\u6ca1\u60f3\u5230\u771f\u7684\u53ef\u4ee5\u7528\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Write your MySQL query statement below\nSELECT B.name\nFROM Vote AS A \nLEFT JOIN Candidate AS B \nON A.candidateId=B.id\nGROUP BY B.name\nORDER BY COUNT(B.name) DESC\nLIMIT 1\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\"># Write your MySQL query <\/span><span style=\"color: #569CD6\">statement<\/span><span style=\"color: #D4D4D4\"> below<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> B.name<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> Vote <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> A <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">LEFT JOIN<\/span><span style=\"color: #D4D4D4\"> Candidate <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> B <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">ON<\/span><span style=\"color: #D4D4D4\"> A.candidateId=B.id<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">GROUP BY<\/span><span style=\"color: #D4D4D4\"> B.name<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">ORDER BY<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">COUNT<\/span><span style=\"color: #D4D4D4\">(B.name) <\/span><span style=\"color: #569CD6\">DESC<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">LIMIT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>ORDER BY COUNT( )<\/p>\n","protected":false},"author":1,"featured_media":7504,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/8104"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=8104"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/8104\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/7504"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=8104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=8104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=8104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}