{"id":104,"date":"2025-02-05T19:25:54","date_gmt":"2025-02-05T11:25:54","guid":{"rendered":"https:\/\/www.handytoo.com\/?p=104"},"modified":"2025-02-05T19:25:54","modified_gmt":"2025-02-05T11:25:54","slug":"mysql%e4%b8%80%e5%b9%b412%e4%b8%aa%e6%9c%88%e6%95%b0%e6%8d%ae%e7%bb%9f%e8%ae%a1%e6%9f%a5%e8%af%a2%ef%bc%8c%e6%b2%a1%e6%95%b0%e6%8d%ae%e8%a1%a50","status":"publish","type":"post","link":"https:\/\/www.handytoo.com\/?p=104","title":{"rendered":"Mysql\u4e00\u5e7412\u4e2a\u6708\u6570\u636e\u7edf\u8ba1\u67e5\u8be2\uff0c\u6ca1\u6570\u636e\u88650"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u80cc\u666f<\/h2>\n\n\n\n<p>\u4e2d\u5c0f\u9879\u76ee\uff08\u975e\u5927\u6570\u636e\u9879\u76ee\uff09\u4e2d\u603b\u662f\u6709\u7edf\u8ba1\u62a5\u8868\u6a21\u5757\uff0c\u5176\u4e2d\u6bcf\u6b21\u90fd\u6709\u5bf912\u4e2a\u6708\u6570\u636e\u7edf\u8ba1\u7684\u9700\u6c42\uff0c\u7279\u522b\u7559\u4f5c\u8bb0\u5f55<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u6218<\/h2>\n\n\n\n<p>\u8fd9\u4e2a\u5b9e\u4f8b\u662f\u7edf\u8ba1\u6bcf\u4e2a\u6708\u7528\u6237\u6ce8\u518c\u603b\u91cf<\/p>\n\n\n\n<p>\u5982\u679c\u6570\u636e\u8868\u4e2dcreate_time\u4e3adatetime\u683c\u5f0f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select \nsum(case month(create_time) when '1' then 1 else 0 end) as \u4e00\u6708,\nsum(case month(create_time) when '2' then 1 else 0 end) as \u4e8c\u6708,\nsum(case month(create_time) when '3' then 1 else 0 end) as \u4e09\u6708,\nsum(case month(create_time) when '4' then 1 else 0 end) as \u56db\u6708,\nsum(case month(create_time) when '5' then 1 else 0 end) as \u4e94\u6708,\nsum(case month(create_time) when '6' then 1 else 0 end) as \u516d\u6708,\nsum(case month(create_time) when '7' then 1 else 0 end) as \u4e03\u6708,\nsum(case month(create_time) when '8' then 1 else 0 end) as \u516b\u6708,\nsum(case month(create_time) when '9' then 1 else 0 end) as \u4e5d\u6708,\nsum(case month(create_time) when '10' then 1 else 0 end) as \u5341\u6708,\nsum(case month(create_time) when '11' then 1 else 0 end) as \u5341\u4e00\u6708,\nsum(case month(create_time) when '12' then 1 else 0 end) as \u5341\u4e8c\u6708\nfrom tbl_user\nwhere year(create_time) in ('2018');\n<\/pre>\n\n\n\n<p>\u5982\u679c\u6570\u636e\u8868\u4e2dcreate_time\u4e3a\u65f6\u95f4\u6233\uff0c\u9700\u8981\u8fdb\u884c\u65f6\u95f4\u6233\u8f6c\u6362<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select \nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '1' then 1 else 0 end) as \u4e00\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '2' then 1 else 0 end) as \u4e8c\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '3' then 1 else 0 end) as \u4e09\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '4' then 1 else 0 end) as \u56db\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '5' then 1 else 0 end) as \u4e94\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '6' then 1 else 0 end) as \u516d\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '7' then 1 else 0 end) as \u4e03\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '8' then 1 else 0 end) as \u516b\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '9' then 1 else 0 end) as \u4e5d\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '10' then 1 else 0 end) as \u5341\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '11' then 1 else 0 end) as \u5341\u4e00\u6708,\nsum(case month(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) when '12' then 1 else 0 end) as \u5341\u4e8c\u6708\nfrom tbl_user\nwhere year(FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%S')) in ('2018');<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u4e2d\u5c0f\u9879\u76ee\uff08\u975e\u5927\u6570\u636e\u9879\u76ee\uff09\u4e2d\u603b\u662f\u6709\u7edf\u8ba1\u62a5\u8868\u6a21\u5757\uff0c\u5176\u4e2d\u6bcf\u6b21\u90fd\u6709\u5bf912\u4e2a\u6708\u6570\u636e\u7edf\u8ba1\u7684\u9700\u6c42\uff0c\u7279\u522b\u7559\u4f5c\u8bb0\u5f55 \u5b9e\u6218  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[29],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-database","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=104"}],"version-history":[{"count":1,"href":"https:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}