{"id":3900,"date":"2023-11-01T09:35:53","date_gmt":"2023-11-01T01:35:53","guid":{"rendered":"https:\/\/white-night.club\/?p=3900"},"modified":"2023-11-09T11:07:44","modified_gmt":"2023-11-09T03:07:44","slug":"ad118","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/01\/ad118\/","title":{"rendered":"1113.\u00a0\u62a5\u544a\u7684\u8bb0\u5f55"},"content":{"rendered":"\n<p>\u52a8\u4f5c\u8868\uff1a<code>Actions<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+---------------+---------+\n| Column Name   | Type    |\n+---------------+---------+\n| user_id       | int     |\n| post_id       | int     |\n| action_date   | date    | \n| action        | enum    |\n| extra         | varchar |\n+---------------+---------+\n\u6b64\u8868\u53ef\u80fd\u4f1a\u6709\u91cd\u590d\u7684\u884c\u3002\naction \u5b57\u6bb5\u662f ENUM \u7c7b\u578b\u7684\uff0c\u5305\u542b:('view', 'like', 'reaction', 'comment', <em><strong>'<\/strong><\/em>report<em><strong>'<\/strong><\/em>, 'share')\nextra \u5305\u542b\u5173\u4e8e action \u7684\u53ef\u9009\u4fe1\u606f\uff0c\u4f8b\u5982\u4e3e\u62a5\u7684\u539f\u56e0\u6216\u53cd\u9988\u7684\u7c7b\u578b\u3002\n\u5f53 action \u4e3a 'report' \u65f6 extra \u4e0d\u4f1a\u4e3a NULL\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\uff0c\u9488\u5bf9\u6bcf\u4e2a\u4e3e\u62a5\u539f\u56e0\u7edf\u8ba1\u6628\u5929\u7684\u4e3e\u62a5\u5e16\u5b50\u6570\u91cf\u3002\u5047\u8bbe\u4eca\u5929\u662f&nbsp;<code>2019-07-05<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868&nbsp;<strong>\u65e0\u987a\u5e8f\u8981\u6c42&nbsp;<\/strong>\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u793a\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a\u8f93\u5165\uff1a<\/strong> Actions table: +&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+ | user_id | post_id | action_date | action | extra  | +&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+ | 1       | 1       | 2019-07-01  | view   | null   | | 1       | 1       | 2019-07-01  | like   | null   | | 1       | 1       | 2019-07-01  | share  | null   | | 2       | 4       | 2019-07-04  | view   | null   | | 2       | 4       | 2019-07-04  | report | spam   | | 3       | 4       | 2019-07-04  | view   | null   | | 3       | 4       | 2019-07-04  | report | spam   | | 4       | 3       | 2019-07-02  | view   | null   | | 4       | 3       | 2019-07-02  | report | spam   | | 5       | 2       | 2019-07-04  | view   | null   | | 5       | 2       | 2019-07-04  | report | racism | | 5       | 5       | 2019-07-04  | view   | null   | | 5       | 5       | 2019-07-04  | report | racism | +&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+ <strong>\u8f93\u51fa\uff1a<\/strong> +&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+ | report_reason | report_count | +&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+ | spam          | 1            | | racism        | 2            | +&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+  <strong>\u89e3\u91ca\uff1a<\/strong>\u6ce8\u610f\uff0c\u6211\u4eec\u53ea\u5173\u5fc3\u4e3e\u62a5\u5e16\u6570\u91cf\u975e\u96f6\u7684\u4e3e\u62a5\u539f\u56e0\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>DISTINCT<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e4b\u524d\u770b\u4e86\u4e2a\u89e3\u91ca\uff0c\u8bf4\u5f53SELECT\u6709\u591a\u4e2a\u5bf9\u8c61\u7684\u65f6\u5019\u5c31\u4e0d\u80fd\u7528DISTINCT\u53bb\u91cd\uff0c\u56e0\u4e3a\u4e0d\u4f1a\u751f\u6548\u3002\u4f46\u5b83\u6ca1\u63d0SELECT xxx,COUNT\u8fd9\u79cd\uff0c\u56e0\u4e3a\u5728\u805a\u5408\u51fd\u6570\u91cc\u9762\u8fd8\u662f\u53ef\u4ee5\u7528DISTINTCT\u7684\uff0c\u641e\u5f97\u6211\u60f3\u53bb\u91cd\u60f3\u4e86\u534a\u5929\uff0c\u53cd\u601d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT extra AS report_reason,COUNT(DISTINCT post_id) AS report_count\r\nFROM Actions\r\nWHERE extra IS NOT NULL AND action='report' AND action_date='2019-07-04'\r\nGROUP BY extra<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aDISTINCT<\/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\/3900"}],"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=3900"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3900\/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=3900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}