{"id":4785,"date":"2023-11-10T11:42:27","date_gmt":"2023-11-10T03:42:27","guid":{"rendered":"https:\/\/white-night.club\/?p=4785"},"modified":"2023-11-10T11:42:40","modified_gmt":"2023-11-10T03:42:40","slug":"ad143","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/10\/ad143\/","title":{"rendered":"1412.\u00a0\u67e5\u627e\u6210\u7ee9\u5904\u4e8e\u4e2d\u6e38\u7684\u5b66\u751f"},"content":{"rendered":"\n<p>\u8868:&nbsp;<code>Student<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+---------------------+---------+\n| Column Name         | Type    |\n+---------------------+---------+\n| student_id          | int     |\n| student_name        | varchar |\n+---------------------+---------+\nstudent_id \u662f\u8be5\u8868\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217)\u3002\nstudent_name \u5b66\u751f\u540d\u5b57\u3002<\/pre>\n\n\n\n<p>\u8868:&nbsp;<code>Exam<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+---------------+---------+\n| Column Name   | Type    |\n+---------------+---------+\n| exam_id       | int     |\n| student_id    | int     |\n| score         | int     |\n+---------------+---------+\n(exam_id, student_id) \u662f\u8be5\u8868\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u7684\u7ec4\u5408)\u3002\n\u5b66\u751f student_id \u5728\u6d4b\u9a8c exam_id \u4e2d\u5f97\u5206\u4e3a score\u3002\n<\/pre>\n\n\n\n<p>\u6210\u7ee9\u5904\u4e8e\u4e2d\u6e38\u7684\u5b66\u751f\u662f\u6307\u81f3\u5c11\u53c2\u52a0\u4e86\u4e00\u6b21\u6d4b\u9a8c,&nbsp;\u4e14\u5f97\u5206\u65e2\u4e0d\u662f\u6700\u9ad8\u5206\u4e5f\u4e0d\u662f\u6700\u4f4e\u5206\u7684\u5b66\u751f\u3002<\/p>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\uff0c\u627e\u51fa\u5728&nbsp;<strong>\u6240\u6709<\/strong>&nbsp;\u6d4b\u9a8c\u4e2d\u90fd\u5904\u4e8e\u4e2d\u6e38\u7684\u5b66\u751f&nbsp;<code>(student_id, student_name)<\/code>\u3002\u4e0d\u8981\u8fd4\u56de\u4ece\u6765\u6ca1\u6709\u53c2\u52a0\u8fc7\u6d4b\u9a8c\u7684\u5b66\u751f\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868\u6309\u7167&nbsp;<code>student_id<\/code>&nbsp;\u6392\u5e8f\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a\u8f93\u5165\uff1a<\/strong> Student \u8868\uff1a +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+ | student_id  | student_name  | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+ | 1           | Daniel        | | 2           | Jade          | | 3           | Stella        | | 4           | Jonathan      | | 5           | Will          | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+ Exam \u8868\uff1a +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+ | exam_id    | student_id   | score     | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+ | 10         |     1        |    70     | | 10         |     2        |    80     | | 10         |     3        |    90     | | 20         |     1        |    80     | | 30         |     1        |    70     | | 30         |     3        |    80     | | 30         |     4        |    90     | | 40         |     1        |    60     | | 40         |     2        |    70     | | 40         |     4        |    80     | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+ <strong>\u8f93\u51fa\uff1a<\/strong> +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+ | student_id  | student_name  | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+ | 2           | Jade          | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+ <strong>\u89e3\u91ca\uff1a<\/strong> \u5bf9\u4e8e\u6d4b\u9a8c 1: \u5b66\u751f 1 \u548c 3 \u5206\u522b\u83b7\u5f97\u4e86\u6700\u4f4e\u5206\u548c\u6700\u9ad8\u5206\u3002 \u5bf9\u4e8e\u6d4b\u9a8c 2: \u5b66\u751f 1 \u65e2\u83b7\u5f97\u4e86\u6700\u9ad8\u5206, \u4e5f\u83b7\u5f97\u4e86\u6700\u4f4e\u5206\u3002 \u5bf9\u4e8e\u6d4b\u9a8c 3 \u548c 4: \u5b66\u751f 1 \u548c 4 \u5206\u522b\u83b7\u5f97\u4e86\u6700\u4f4e\u5206\u548c\u6700\u9ad8\u5206\u3002 \u5b66\u751f 2 \u548c 5 \u6ca1\u6709\u5728\u4efb\u4e00\u573a\u6d4b\u9a8c\u4e2d\u83b7\u5f97\u4e86\u6700\u9ad8\u5206\u6216\u8005\u6700\u4f4e\u5206\u3002 \u56e0\u4e3a\u5b66\u751f 5 \u4ece\u6765\u6ca1\u6709\u53c2\u52a0\u8fc7\u4efb\u4f55\u6d4b\u9a8c, \u6240\u4ee5\u4ed6\u88ab\u6392\u9664\u4e8e\u7ed3\u679c\u8868\u3002 \u7531\u6b64, \u6211\u4eec\u4ec5\u4ec5\u8fd4\u56de\u5b66\u751f 2 \u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>NOT IN+ALL<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u67e5\u8be2\u67d0\u4e2a\u5728\u5168\u90e8group\u4e2d\uff0c\u90fd\u5c0f\u4e8e\u6700\u5927\u503c\uff0c\u4f46\u5927\u4e8e\u6700\u5c0f\u503c\u7684\u67d0\u4e2a\u4e2d\u95f4\u503c\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u9996\u5148\u5f97\u9009\u51fa\u4e0d\u540c\u7684\u5206\u7ec4\uff0c\u518d\u7528\u6bcf\u4e2astudent\u7684score\u53bb\u6bd4\u8f83\u6bcf\u4e2a\u7ec4\u7684\u6700\u5927\u503c\u548c\u6700\u5c0f\u503c\u3002\u5982\u679c\u5728\u4efb\u610f\u5206\u7ec4\u4e2d\u62ff\u8fc7\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\uff0c\u90a3\u4e48\u5c31\u628a\u5bf9\u5e94\u7684student_id\u6392\u9664\u51fa\u7ed3\u679c\u96c6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT DISTINCT A.student_id,B.student_name\r\nFROM EXAM AS A \r\nLEFT JOIN Student AS B \r\nON A.student_id=B.student_id\r\nWHERE A.student_id NOT IN(\r\n  SELECT C.student_id\r\n  FROM EXAM AS C\r\n  WHERE C.score>=(\r\n    SELECT MAX(score) FROM EXAM\r\n    WHERE C.exam_id=exam_id\r\n    GROUP BY exam_id)\r\n  OR C.score&lt;=(\r\n    SELECT MIN(score) FROM EXAM\r\n    WHERE exam_id=C.exam_id\r\n    GROUP BY exam_id\r\n  )\r\n)\r\nORDER BY A.student_id ASC<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u67e5\u8be2\u4ecb\u4e8e\u6700\u5927\u548c\u6700\u5c0f\u4e4b\u95f4\u7684\u503c<\/p>\n","protected":false},"author":1,"featured_media":2827,"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\/4785"}],"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=4785"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4785\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=4785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=4785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=4785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}