{"id":707,"date":"2012-06-29T20:38:22","date_gmt":"2012-06-29T20:38:22","guid":{"rendered":"http:\/\/www.attob.com\/blog\/?p=707"},"modified":"2012-06-29T20:38:22","modified_gmt":"2012-06-29T20:38:22","slug":"mysql-group-by-with-%e6%97%a5%e4%bb%98","status":"publish","type":"post","link":"https:\/\/www.attob.com\/blog2\/2012\/06\/29\/mysql-group-by-with-%e6%97%a5%e4%bb%98\/","title":{"rendered":"MYSQL Group By with \u65e5\u4ed8"},"content":{"rendered":"<h4><code>select count(*), <\/code><code>DATE_FORMAT<\/code><code>(date_field_name,<\/code><code>\"%Y-%m-%d\"<\/code><code>) as created_day <\/code><code>FROM<\/code> <code>table_name <\/code><code>GROUP<\/code> <code>BY<\/code> <code>created_day<\/code><\/h4>\n<p><code>select count(*), <\/code><code>DATE_FORMAT<\/code><code>(date_field_name,<\/code><code>\"%Y-%m\"<\/code><code>) as created_month <\/code><code>FROM<\/code> <code>table_name <\/code><code>GROUP<\/code> <code>BY<\/code> <code>created_month<\/code><br \/>\n<code>select count(*), <\/code><code>DATE_FORMAT<\/code><code>(<code>date_field_name<\/code>,<\/code><code>\"%Y\"<\/code><code>) as created_year <\/code><code>FROM<\/code> <code>table_name <\/code><code>GROUP<\/code> <code>BY<\/code> <code>created_year<\/code><code><\/code><br \/>\n<code>\u203b %Y-%m-%d<\/code> \u7b49\u306e\u90e8\u5206\u306f\u305d\u306e\u307e\u307e\u4f7f\u3044\u3001\u6570\u5b57\u306a\u3069\u306b\u5909\u66f4\u3057\u306a\u3044\u3002<br \/>\n&nbsp;<\/p>\n<h4>\u4ed6\u306e\u65b9\u6cd5<\/h4>\n<h4><\/h4>\n<h4>\u6708\u5225\u306e\u53d6\u5f97<\/h4>\n<p>SELECT SUM(field) FROM table GROUP BY DATE_FORMAT(date_field, &#8216;%Y%m&#8217;);<\/p>\n<h4>\u65e5\u4ed8\u5225\u306e\u53d6\u5f97<\/h4>\n<p>SELECT SUM(field) FROM table GROUP BY DATE_FORMAT(date_field, &#8216;%Y%m%d&#8217;);<\/p>\n<h4>\u66dc\u65e5\u5225\u306e\u53d6\u5f97<\/h4>\n<p>SELECT SUM(field) FROM table GROUP BY WEEKOFDAY(date_field);<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>select count(*), DATE_FORMAT(date_field_name,&#8221;%Y-%m-%d&#8221;) as created_day FROM table_name GROUP BY created_day s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-707","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/posts\/707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/comments?post=707"}],"version-history":[{"count":0,"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/posts\/707\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/media?parent=707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/categories?post=707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.attob.com\/blog2\/wp-json\/wp\/v2\/tags?post=707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}