{"id":3258,"date":"2025-12-18T15:29:18","date_gmt":"2025-12-18T06:29:18","guid":{"rendered":"https:\/\/www.agile-software.site\/?p=3258"},"modified":"2025-12-18T15:29:19","modified_gmt":"2025-12-18T06:29:19","slug":"%e3%82%b9%e3%83%94%e3%83%ab%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%99%e3%82%8b%e5%a0%b4%e5%90%88%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6%e3%81%ae%e3%83%a6%e3%83%bc%e3%82%b9%e3%82%b1%e3%83%bc%e3%82%b9","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=3258","title":{"rendered":"\u30b9\u30d4\u30eb\u304c\u767a\u751f\u3059\u308b\u5834\u5408\u306b\u3064\u3044\u3066\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u300c\u6700\u521d\u306e\u96c6\u8a08\u30ce\u30fc\u30c9\u300d\u3067\u4f55\u304c\u8d77\u304d\u3066\u3044\u305f\u304b<\/h2>\n\n\n\n<p>Snowflake\u304c\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u969b\u3001\u51e6\u7406\u3092\u300c\u30ce\u30fc\u30c9\uff08\u5de5\u7a0b\uff09\u300d\u306b\u5206\u89e3\u3057\u307e\u3059\u30022\u3064\u76ee\u306e\u30af\u30a8\u30ea\u3067\u306f\u4ee5\u4e0b\u306e\u9806\u3067\u51e6\u7406\u304c\u9032\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f<\/strong>: 3\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092JOIN\u3059\u308b\u3002<\/li>\n\n\n\n<li><strong>\u3010\u6700\u521d\u306e\u96c6\u8a08\u30ce\u30fc\u30c9\u3011<\/strong>: <code>GROUP BY cd_gender, cs_order_number<\/code> \u3092\u5b9f\u884c\u3002<strong>\u2190\u3053\u3053\u3067\u5927\u4e8b\u4ef6\u304c\u767a\u751f\uff01<\/strong><\/li>\n\n\n\n<li><strong>2\u756a\u76ee\u306e\u96c6\u8a08\u30ce\u30fc\u30c9<\/strong>: \u305d\u306e\u7d50\u679c\u3092\u3055\u3089\u306b <code>GROUP BY cd_gender<\/code> \u3067\u307e\u3068\u3081\u308b\u3002<\/li>\n<\/ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>-- &#x274c; \u30b9\u30d4\u30eb\uff08\u30e1\u30e2\u30ea\u4e0d\u8db3\uff09\u304c\u767a\u751f\u3059\u308b\u30af\u30a8\u30ea\nSELECT \n    cd_gender,\n    AVG(lp) average_list_price,\n    AVG(sp) average_sales_price,\n    AVG(qu) average_quantity\nFROM (\n    -- \u3010\u3053\u3053\u304c\u554f\u984c\uff01\u3011\u30b5\u30d6\u30af\u30a8\u30ea\n    SELECT \n        cd_gender,\n        cs_order_number, -- &#x1f448; \u6ce8\u6587\u756a\u53f7\uff08\u6570\u767e\u4e07\u301c\u6570\u5343\u4e07\u7a2e\u985e\u3042\u308b\uff09\n        AVG(cs_list_price) lp,\n        AVG(cs_sales_price) sp,\n        AVG(cs_quantity) qu\n    FROM catalog_sales, date_dim, customer_demographics\n    WHERE cs_sold_date_sk = d_date_sk\n      AND cs_bill_cdemo_sk = cd_demo_sk\n      AND d_year = 2000\n    GROUP BY \n        cd_gender, \n        cs_order_number -- &#x1f448; \u3053\u3053\u3067\u300c\u6027\u5225\u00d7\u6ce8\u6587\u756a\u53f7\u300d\u306e\u6570\u5343\u4e07\u500b\u306e\u30d0\u30b1\u30c4\u3092\u4f5c\u308d\u3046\u3068\u3057\u3066\u30e1\u30e2\u30ea\u304c\u30d1\u30f3\u30af\uff01\n) inner_query\nGROUP BY \n    cd_gender; -- \u6700\u5f8c\u306b\u6570\u500b\uff08\u6027\u5225\uff09\u306b\u307e\u3068\u3081\u3066\u3044\u308b\u304c\u3001\u524d\u306e\u5de5\u7a0b\u3067\u3059\u3067\u306b\u30e1\u30e2\u30ea\u304c\u6ea2\u308c\u3066\u3044\u308b<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u306a\u305c\u3053\u3053\u3067\u30b9\u30d4\u30eb\u3059\u308b\u306e\u304b\uff1f<\/h3>\n\n\n\n<p><code>cs_order_number<\/code>\uff08\u6ce8\u6587\u756a\u53f7\uff09\u306f\u975e\u5e38\u306b\u7a2e\u985e\u304c\u591a\u3044\u305f\u3081\u3001Snowflake\u306f\u3053\u306e\u300c\u6700\u521d\u306e\u96c6\u8a08\u30ce\u30fc\u30c9\u300d\u3067\u3001<strong>\u6570\u767e\u4e07\u301c\u6570\u5343\u4e07\u4ef6\u306e\u30e6\u30cb\u30fc\u30af\u306a\u7d44\u307f\u5408\u308f\u305b<\/strong>\u3092\u30e1\u30e2\u30ea\u4e0a\u306b\u4fdd\u6301\u3057\u3088\u3046\u3068\u3057\u307e\u3059\u3002 \u3057\u304b\u3057\u3001\u30a6\u30a7\u30a2\u30cf\u30a6\u30b9\u306e\u30e1\u30e2\u30ea\u5bb9\u91cf\u3092\u8d85\u3048\u3066\u3057\u307e\u3046\u305f\u3081\u3001\u30c7\u30fc\u30bf\u304c\u30c7\u30a3\u30b9\u30af\u306b\u6ea2\u308c\uff08<strong>\u30b9\u30d4\u30eb<\/strong>\uff09\u3001\u51e6\u7406\u304c\u6975\u7aef\u306b\u9045\u304f\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u300c\u66f8\u304d\u76f4\u3057\u300d\u306b\u3088\u308b\u4fee\u6b63\u306e\u6b63\u4f53<\/h2>\n\n\n\n<p>\u8aac\u660e\u6587\u306b\u3042\u308b\u300c<code>cs_order_number<\/code> \u3092\u524a\u9664\u3057\u3066\u5b9f\u884c\u3059\u308b\u3060\u3051\u300d\u3068\u3044\u3046\u4fee\u6b63\u306f\u3001**\u300c\u6700\u521d\u306e\u96c6\u8a08\u30ce\u30fc\u30c9\u3067\u306e\u8ca0\u62c5\u3092 100\u4e07\u5206\u306e1 \u4ee5\u4e0b\u306b\u3059\u308b\u300d**\u3068\u3044\u3046\u5287\u7684\u306a\u6539\u5584\u7b56\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4fee\u6b63\u524d<\/strong>: \u6570\u5343\u4e07\u4ef6\u306e\u300c\u6ce8\u6587 \u00d7 \u6027\u5225\u300d\u306e\u30da\u30a2\u3092\u7ba1\u7406\u3059\u308b\u3002<\/li>\n\n\n\n<li><strong>\u4fee\u6b63\u5f8c<\/strong>: \u6570\u4ef6\u306e\u300c\u6027\u5225\u300d\u306e\u30b0\u30eb\u30fc\u30d7\u3060\u3051\u3092\u7ba1\u7406\u3059\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>-- &#x2705; \u30e1\u30e2\u30ea\u5185\u3067\u5b8c\u7d50\u3057\u3001\u9ad8\u901f\u306b\u7d42\u308f\u308b\u30af\u30a8\u30ea\nSELECT \n    cd_gender, -- &#x1f448; \u6700\u521d\u304b\u3089\u300c\u6027\u5225\u300d\u3060\u3051\u3092\u898b\u308b\n    AVG(cs_list_price) lp,\n    AVG(cs_sales_price) sp,\n    AVG(cs_quantity) qu\nFROM catalog_sales, date_dim, customer_demographics\nWHERE cs_sold_date_sk = d_date_sk\n  AND cs_bill_cdemo_sk = cd_demo_sk\n  AND d_year = 2000\nGROUP BY \n    cd_gender; -- &#x1f448; \u30b0\u30eb\u30fc\u30d7\u306f\u300c\u7537\u30fb\u5973\u30fb\u4e0d\u660e\u300d\u306e\u6570\u500b\u3060\u3051\u3002\u30e1\u30e2\u30ea\u306b\u4f59\u88d5\u3067\u53ce\u307e\u308b\uff01<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u3059\u3079\u3066\u306e\u51e6\u7406\u304c\u30e1\u30e2\u30ea\u5185\u3067\u5b8c\u7d50\uff08\u30a4\u30f3\u30e1\u30e2\u30ea\u51e6\u7406\uff09\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u30b9\u30d4\u30eb\u304c\u89e3\u6d88\u3055\u308c\u308b\u305f\u3081\u3001\u5b9f\u884c\u6642\u9593\u304c\u534a\u5206\uff08\u3042\u308b\u3044\u306f\u305d\u308c\u4ee5\u4e0a\uff09\u306b\u77ed\u7e2e\u3055\u308c\u308b\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u3053\u306e\u4e8b\u4f8b\u304b\u3089\u5b66\u3079\u308b\u300cSnowflake\u904b\u7528\u306e\u9244\u5247\u300d<\/h2>\n\n\n\n<p>\u3053\u306e\u8aac\u660e\u6587\u304c\u6559\u3048\u3066\u304f\u308c\u3066\u3044\u308b\u6700\u3082\u91cd\u8981\u306a\u6559\u8a13\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u4e0d\u5fc5\u8981\u306a\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u907f\u3051\u308b<\/strong>: \u6700\u7d42\u7684\u306b\u300c\u6027\u5225\u3054\u3068\u300d\u306e\u96c6\u8a08\u304c\u898b\u305f\u3044\u3060\u3051\u306a\u3089\u3001\u9014\u4e2d\u3067\u300c\u6ce8\u6587\u756a\u53f7\u3054\u3068\u300d\u306b\u7d30\u304b\u304f\u5206\u3051\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/li>\n\n\n\n<li><strong>\u30b5\u30d6\u30af\u30a8\u30ea\uff08\u30cd\u30b9\u30c8\uff09\u306e\u7f60<\/strong>: \u300c\u4e00\u5ea6\u4e2d\u9593\u96c6\u8a08\u3057\u305f\u307b\u3046\u304c\u901f\u304f\u306a\u308b\u304b\u3082\uff1f\u300d\u3068\u3044\u3046\u826f\u304b\u308c\u3068\u601d\u3063\u305f\u5de5\u592b\u304c\u3001\u5206\u6563\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u306f\u9006\u306b\u300c\u30c7\u30fc\u30bf\u79fb\u52d5\u3068\u30e1\u30e2\u30ea\u6d88\u8cbb\u300d\u3092\u5897\u3084\u3057\u3066\u4ec7\u3068\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u96c6\u8a08\u30ce\u30fc\u30c9\u3092\u610f\u8b58\u3059\u308b<\/strong>: \u30af\u30a8\u30ea\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3092\u898b\u3066\u300cAggregate\uff08\u96c6\u8a08\uff09\u300d\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3044\u305f\u308a\u3001\u30b9\u30d4\u30eb\u304c\u767a\u751f\u3057\u3066\u3044\u305f\u3089\u3001**\u300c\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u5316\u3001\u672c\u5f53\u306b\u305d\u306e\u7c92\u5ea6\uff08\u7d30\u304b\u3055\uff09\u3067\u3084\u308b\u5fc5\u8981\u304c\u3042\u308b\uff1f\u300d**\u3068\u7591\u3046\u306e\u304c\u9ad8\u901f\u5316\u306e\u8fd1\u9053\u3067\u3059\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>1. \u300c\u6700\u521d\u306e\u96c6\u8a08\u30ce\u30fc\u30c9\u300d\u3067\u4f55\u304c\u8d77\u304d\u3066\u3044\u305f\u304b Snowflake\u304c\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u969b\u3001\u51e6\u7406\u3092\u300c\u30ce\u30fc\u30c9\uff08\u5de5\u7a0b\uff09\u300d\u306b\u5206\u89e3\u3057\u307e\u3059\u30022\u3064\u76ee\u306e\u30af\u30a8\u30ea\u3067\u306f\u4ee5\u4e0b\u306e\u9806\u3067\u51e6\u7406\u304c\u9032\u307f\u307e\u3059\u3002 \u306a\u305c\u3053\u3053\u3067\u30b9\u30d4\u30eb\u3059\u308b\u306e\u304b\uff1f cs_order_nu<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3258","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3258"}],"version-history":[{"count":1,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3258\/revisions"}],"predecessor-version":[{"id":3259,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3258\/revisions\/3259"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}