{"id":3256,"date":"2023-10-23T11:11:09","date_gmt":"2023-10-23T03:11:09","guid":{"rendered":"https:\/\/white-night.club\/?p=3256"},"modified":"2023-11-09T11:07:47","modified_gmt":"2023-11-09T03:07:47","slug":"ad88","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/23\/ad88\/","title":{"rendered":"1587.\u00a0\u94f6\u884c\u8d26\u6237\u6982\u8981 II"},"content":{"rendered":"\n<p>\u8868:&nbsp;<code>Users<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+--------------+---------+\n| Column Name  | Type    |\n+--------------+---------+\n| account      | int     |\n| name         | varchar |\n+--------------+---------+\naccount \u662f\u8be5\u8868\u7684\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217)\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u90fd\u5305\u542b\u94f6\u884c\u4e2d\u6bcf\u4e2a\u7528\u6237\u7684\u5e10\u53f7\u3002\n\u8868\u4e2d\u4e0d\u4f1a\u6709\u4e24\u4e2a\u7528\u6237\u5177\u6709\u76f8\u540c\u7684\u540d\u79f0\u3002\n<\/pre>\n\n\n\n<p>\u8868:&nbsp;<code>Transactions<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+---------------+---------+\n| Column Name   | Type    |\n+---------------+---------+\n| trans_id      | int     |\n| account       | int     |\n| amount        | int     |\n| transacted_on | date    |\n+---------------+---------+\ntrans_id \u662f\u8be5\u8868\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217)\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u5305\u542b\u4e86\u6240\u6709\u8d26\u6237\u7684\u4ea4\u6613\u6539\u53d8\u60c5\u51b5\u3002\n\u5982\u679c\u7528\u6237\u6536\u5230\u4e86\u94b1, \u90a3\u4e48\u91d1\u989d\u662f\u6b63\u7684; \u5982\u679c\u7528\u6237\u8f6c\u4e86\u94b1, \u90a3\u4e48\u91d1\u989d\u662f\u8d1f\u7684\u3002\n\u6240\u6709\u8d26\u6237\u7684\u8d77\u59cb\u4f59\u989d\u4e3a 0\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848,&nbsp;&nbsp;\u62a5\u544a\u4f59\u989d\u9ad8\u4e8e 10000 \u7684\u6240\u6709\u7528\u6237\u7684\u540d\u5b57\u548c\u4f59\u989d.&nbsp;\u8d26\u6237\u7684\u4f59\u989d\u7b49\u4e8e\u5305\u542b\u8be5\u8d26\u6237\u7684\u6240\u6709\u4ea4\u6613\u7684\u603b\u548c\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868\u5355&nbsp;<strong>\u65e0\u987a\u5e8f\u8981\u6c42<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u67e5\u8be2\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><code><strong>\u8f93\u5165\uff1a<\/strong> Users<\/code> table: +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+ | account    | name         | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+ | 900001     | Alice        | | 900002     | Bob          | | 900003     | Charlie      | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+ <code>Transactions<\/code> table: +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+ | trans_id   | account    | amount     | transacted_on | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+ | 1          | 900001     | 7000       |  2020-08-01   | | 2          | 900001     | 7000       |  2020-09-01   | | 3          | 900001     | -3000      |  2020-09-02   | | 4          | 900002     | 1000       |  2020-09-12   | | 5          | 900003     | 6000       |  2020-08-07   | | 6          | 900003     | 6000       |  2020-09-07   | | 7          | 900003     | -4000      |  2020-09-11   | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+ <strong>\u8f93\u51fa\uff1a<\/strong> +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+ | <code>name    <\/code>   | <code>balance  <\/code>  | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+ | Alice      | 11000      | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+ <strong>\u89e3\u91ca\uff1a<\/strong> Alice \u7684\u4f59\u989d\u4e3a(7000 + 7000 &#8211; 3000) = 11000. Bob \u7684\u4f59\u989d\u4e3a1000. Charlie \u7684\u4f59\u989d\u4e3a(6000 + 6000 &#8211; 4000) = 8000.<\/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>\u5de6\u8054\u7ed3<\/em><\/cite><\/blockquote>\n\n\n\n<p>Balance\u8868\u7684\u6240\u6709\u8bb0\u5f55\u80af\u5b9a\u80fd\u548cUsers\u8868\u4e2d\u7684\u4efb\u610f\u4e00\u6761\u8bb0\u5f55\u5339\u914d\u4e0aaccount\uff0c\u6240\u4ee5\u5de6\u8054\u7ed3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.name,SUM(B.amount) AS BALANCE\r\nFROM Users AS A \r\nLEFT JOIN Transactions AS B \r\nON A.account=B.account\r\nGROUP BY A.account\r\nHAVING SUM(B.amount)>10000<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u5de6\u8054\u7ed3<\/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\/3256"}],"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=3256"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3256\/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=3256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}