{"id":4892,"date":"2018-06-22T11:26:46","date_gmt":"2018-06-22T02:26:46","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=4892"},"modified":"2023-05-27T23:16:11","modified_gmt":"2023-05-27T14:16:11","slug":"%e3%80%90sql%e3%80%91%e3%80%8c%e3%82%a6%e3%82%a3%e3%83%b3%e3%83%89%e3%82%a6%e9%96%a2%e6%95%b0%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=4892","title":{"rendered":"\u3010SQL\u3011\u300c\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u300d(OLAP\u95a2\u6570)\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570(OLAP\u95a2\u6570)\u3068\u306f\uff1f<\/h2>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u3001<span style=\"color: #ff0000;\"><strong>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\uff08\u30aa\u30f3\u30e9\u30a4\u30f3\u3067\uff09\u306b\u30c7\u30fc\u30bf\u5206\u6790\u3092\u884c\u3046\u305f\u3081\u306e\u51e6\u7406\u306e\u3053\u3068<\/strong><\/span>\u3067\u3001<span style=\"color: #ff0000;\"><strong>2000\u5e74\u4ee3\u4e2d\u76e4\u304f\u3089\u3044\u304b\u3089\u30c8\u30ec\u30f3\u30c9\u306b\u306a\u3063\u3066\u3044\u308b\u53e4\u304f\u304b\u3089\u3042\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u6280\u8853\u306e\u4e2d\u3067\u3082\u3001\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6280\u8853<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001Oracle\u3084SQL Server\u3067\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u5206\u6790\u95a2\u6570\u300d<\/strong><\/span>\u3068\u547c\u3093\u3067\u3044\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<h2>\u7279\u5fb4\u3092\u4e00\u8a00\u3067\u8a00\u3048\u3070<\/h2>\n<p>\u96c6\u7d04\u6a5f\u80fd\u3092\u306a\u304f\u3057\u305fGROUP BY\u3002\uff08GROUP BY\u306f\u3001\u30ab\u30c3\u30c8\u3068\u96c6\u7d04\u306e\u4e8c\u3064\u306e\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u30a6\u30a4\u30f3\u30c9\u30a6\u95a2\u6570\u306f\u30ab\u30c3\u30c8\u306e\u90e8\u5206\u3060\u3051\u63a1\u7528\u3057\u305f\u6a5f\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\uff09<\/p>\n<h2>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306e\u5404RDBMS\u3067\u306e\u30b5\u30dd\u30fc\u30c8\u72b6\u6cc1<\/h2>\n<p>\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6280\u8853\u3068\u3044\u3046\u3053\u3068\u3082\u3042\u308a\u3001<span style=\"color: #ff0000;\"><strong>\u300cMySQL\u300d<\/strong><\/span>\u3067\u306f\u3053\u306e\u95a2\u6570\u306e\u30b5\u30dd\u30fc\u30c8\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u308c\u4ee5\u5916\u306e\u30e1\u30b8\u30e3\u30fc\u306aRDBMS\uff08Oracle\u3001SQL Server\u3001DB2\u3001PostgreSQL\uff09\u3067\u306f\u305f\u3044\u3066\u3044\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306e\u69cb\u6587<\/h2>\n<pre class=\"lang:default decode:true\">[\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570] OVER ([PARTITION BY &lt;\u5217\u30ea\u30b9\u30c8&gt;] ORDER BY &lt;\u30bd\u30fc\u30c8\u7528\u5217\u30ea\u30b9\u30c8&gt;)<\/pre>\n<h3>PARTITION BY<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u9069\u5fdc\u3059\u308b\u7bc4\u56f2<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u306f\u3001<span style=\"color: #ff0000;\"><strong>GROUP BY\u53e5<\/strong><\/span>\u3067\u96c6\u8a08\u7bc4\u56f2\u3092\u6307\u5b9a\u3059\u308b\u306e\u3068\u4f3c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306b\u3088\u3063\u3066\u3001\u533a\u5207\u3089\u308c\u305f\u7bc4\u56f2\u3092<span style=\"color: #ff0000;\"><strong>\u300c\u30a6\u30a3\u30f3\u30c9\u30a6\u300d<\/strong><\/span>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u3053\u306e\u53e5\u81ea\u4f53\u306f<span style=\"color: #ff0000;\"><strong>\u5fc5\u9808\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u30c6\u30fc\u30d6\u30eb\u5168\u4f53\u304c\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u7bc4\u56f2\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h3>ORDER BY<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u300cPARTITION BY\u300d\u3067\u6307\u5b9a\u3057\u305f\u9069\u5fdc\u7bc4\u56f2\u306e\u4e2d\u306e\u4e26\u3073\u66ff\u3048\u306e\u30eb\u30fc\u30eb<\/strong><\/span>\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u3092\u5b9a\u7fa9\u3067\u304d\u308b\u5834\u6240<\/h2>\n<p>\u57fa\u672c\u306f\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306f\u3001WHERE\u53e5\u3084\u3001GROUP BY\u53e5\u306e\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u7d50\u679c\u3092\u5143\u306b\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067\u3001SELECT\u6587\u306e<span style=\"color: #ff0000;\"><strong>SELECT\u53e5<\/strong><\/span>\u3067\u3057\u304b\u4f7f\u7528\u3057\u307e\u305b\u3093\u3002<\/p>\n<h2>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306e\u7a2e\u985e<\/h2>\n<h3>\u96c6\u7d04\u95a2\u6570<\/h3>\n<ul>\n<li>SUM<\/li>\n<li>AVG<\/li>\n<li>COUNT<\/li>\n<li>MAX<\/li>\n<li>MIN<\/li>\n<\/ul>\n<h3>\u30a6\u30a3\u30f3\u30c9\u30a6\u5c02\u7528\u95a2\u6570<\/h3>\n<ul>\n<li>RANK<\/li>\n<li>DENSE_RANK<\/li>\n<li>ROW_NUMBER<\/li>\n<li>LAG<\/li>\n<li>LEAD<\/li>\n<\/ul>\n<h4>RANK\u95a2\u6570<\/h4>\n<p>\u30e9\u30f3\u30ad\u30f3\u30b0\u3092\u7b97\u51fa\u3057\u307e\u3059\u3002\u540c\u9806\u4f4d\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u5f8c\u7d9a\u306e\u9806\u4f4d\u304c\u6b6f\u629c\u3051\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h4>DENSE_RANK\u95a2\u6570<\/h4>\n<p>\u30e9\u30f3\u30ad\u30f3\u30b0\u3092\u7b97\u51fa\u3057\u307e\u3059\u3002\u540c\u9806\u4f4d\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u5f8c\u7d9a\u306e\u9806\u4f4d\u304c\u6b6f\u629c\u3051\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/strong><\/span><\/p>\n<h4>ROW_NUMBER<\/h4>\n<p>\u4e00\u610f\u306a\u9023\u756a\u3092\u4ed8\u4e0e\u3057\u307e\u3059\u3002<\/p>\n<h4>LAG\u95a2\u6570<\/h4>\n<p>\u4e00\u3064\u524d\u306e\u884c\u306e\u5024\u3092\u53c2\u7167\u3067\u304d\u308b\u3002<\/p>\n<h4>LEAD\u95a2\u6570<\/h4>\n<p>\u4e00\u3064\u5f8c\u306e\u884c\u306e\u5024\u3092\u53c2\u7167\u3067\u304d\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570(OLAP\u95a2\u6570)\u3068\u306f\uff1f \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\uff08\u30aa\u30f3\u30e9\u30a4\u30f3\u3067\uff09\u306b\u30c7\u30fc\u30bf\u5206\u6790\u3092\u884c\u3046\u305f\u3081\u306e\u51e6\u7406\u306e\u3053\u3068\u3067\u30012000\u5e74\u4ee3\u4e2d\u76e4\u304f\u3089\u3044\u304b\u3089\u30c8\u30ec\u30f3\u30c9\u306b\u306a\u3063\u3066\u3044\u308b\u53e4\u304f\u304b\u3089\u3042\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u6280\u8853\u306e\u4e2d\u3067\u3082\u3001\u6bd4\u8f03\u7684\u65b0\u3057 [&hellip;]","protected":false},"author":1,"featured_media":4823,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4892"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4892"}],"version-history":[{"count":20,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4892\/revisions"}],"predecessor-version":[{"id":20587,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4892\/revisions\/20587"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4823"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4892"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}