{"id":2804,"date":"2023-10-18T09:19:50","date_gmt":"2023-10-18T01:19:50","guid":{"rendered":"https:\/\/white-night.club\/?p=2804"},"modified":"2023-11-09T11:07:48","modified_gmt":"2023-11-09T03:07:48","slug":"ad70","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/18\/ad70\/","title":{"rendered":"2853.\u00a0\u6700\u9ad8\u85aa\u6c34\u5dee\u5f02"},"content":{"rendered":"\n<p>\u8868\uff1a<code>Salaries<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+ \n| Column Name | Type    | \n+-------------+---------+ \n| emp_name    | varchar | \n| department  | varchar | \n| salary      | int     |\n+-------------+---------+\n\u8be5\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u7684\u7ec4\u5408\uff09\u662f (emp_name, department)\u3002 \n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u5305\u542b emp_name\u3001department \u548c salary\u3002\u5de5\u7a0b\u90e8\u95e8\u548c\u5e02\u573a\u90e8\u95e8\u81f3\u5c11\u4f1a\u6709\u4e00\u6761\u8bb0\u5f55\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff0c\u8ba1\u7b97&nbsp;<strong>\u5e02\u573a\u90e8\u95e8&nbsp;<\/strong>\u548c&nbsp;<strong>\u5de5\u7a0b\u90e8\u95e8&nbsp;<\/strong>\u4e2d&nbsp;<strong>\u6700\u9ad8&nbsp;<\/strong>\u5de5\u8d44\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u8f93\u51fa\u5de5\u8d44\u7684\u7edd\u5bf9\u5dee\u5f02\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u793a\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nSalaries table:\n+----------+-------------+--------+\n| emp_name | department  | salary |\n+----------+-------------+--------+\n| Kathy    | Engineering | 50000  |\n| Roy      | Marketing   | 30000  |\n| Charles  | Engineering | 45000  |\n| Jack     | Engineering | 85000  | \n| Benjamin | Marketing   | 34000  |\n| Anthony  | Marketing   | 42000  |\n| Edward   | Engineering | 102000 |\n| Terry    | Engineering | 44000  |\n| Evelyn   | Marketing   | 53000  |\n| Arthur   | Engineering | 32000  |\n+----------+-------------+--------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-------------------+\n| salary_difference | \n+-------------------+\n| 49000             | \n+-------------------+\n<strong>\u89e3\u91ca\uff1a<\/strong>\n- \u5de5\u7a0b\u90e8\u95e8\u548c\u5e02\u573a\u90e8\u95e8\u7684\u6700\u9ad8\u5de5\u8d44\u5206\u522b\u4e3a 102,000 \u548c 53,000\uff0c\u56e0\u6b64\u7edd\u5bf9\u5dee\u5f02\u4e3a 49,000\u3002<\/pre>\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>GROUP BY<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u60f3\u627e\u7528\u7a97\u53e3\u51fd\u6570\u6216\u8005in\u7684\u7b80\u5355\u9898\u4f5c\u4e3a\u5165\u95e8\u9898\uff0c\u4e0d\u8fc7\u53cd\u6b63\u90fd\u70b9\u5f00\u4e86\u8fd9\u9053\u90a3\u5c31\u76f4\u63a5\u5199\u5427\u3002\u4e3b\u8981\u5c31\u662f\u5b66\u4e60\u4e0bABS\uff08\uff09\u7684\u7528\u6cd5\u5427\uff0c\u548c\u5176\u4ed6\u8bed\u8a00\u4e00\u6837\u90fd\u662f\u62ff\u6765\u53d6\u7edd\u5bf9\u503c\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT ABS((MAX(A.salary)-MAX(B.salary))) AS salary_difference\r\nFROM Salaries AS A,Salaries AS B\r\nWHERE A.department!=B.department AND A.department=\"Engineering\" AND B.department=\"Marketing\"\r\nGROUP BY A.department<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aGroup BY<\/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\/2804"}],"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=2804"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2804\/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=2804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}