{"id":6748,"date":"2026-07-12T02:05:45","date_gmt":"2026-07-12T10:05:45","guid":{"rendered":"https:\/\/www.gudusoft.com\/data-lineage-examples\/"},"modified":"2026-07-12T02:05:45","modified_gmt":"2026-07-12T10:05:45","slug":"data-lineage-examples","status":"publish","type":"page","link":"https:\/\/www.gudusoft.com\/jp\/%e3%83%87%e3%83%bc%e3%82%bf%e7%b3%bb%e7%b5%b1%e3%81%ae%e4%be%8b\/","title":{"rendered":"\u30c7\u30fc\u30bf\u30ea\u30cd\u30fc\u30b8\u306e\u4f8b\uff1aSQL\u3068\u56f3\u3092\u7528\u3044\u305f6\u3064\u306e\u5b9f\u4f8b"},"content":{"rendered":"<p>\u3042 <strong>\u30c7\u30fc\u30bf\u7cfb\u7d71\u306e\u4f8b<\/strong> \u5177\u4f53\u7684\u306a SQL \u306e\u4f8b\u3067\u3001\u3069\u306e\u30bd\u30fc\u30b9 \u30c6\u30fc\u30d6\u30eb\u3068\u5217\u304c\u3069\u306e\u51fa\u529b\u5217\u306b\u30c7\u30fc\u30bf\u3092\u4f9b\u7d66\u3057\u3001\u30c7\u30fc\u30bf\u304c\u9014\u4e2d\u3067\u3069\u306e\u3088\u3046\u306a\u5909\u63db\u3092\u7d4c\u308b\u304b\u3092\u793a\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e 6 \u3064\u306e\u4f8b\u3067\u306f\u3001\u30c7\u30fc\u30bf \u30a8\u30f3\u30b8\u30cb\u30a2\u304c\u5b9f\u969b\u306b\u906d\u9047\u3059\u308b\u72b6\u6cc1\u3092\u53d6\u308a\u4e0a\u3052\u3066\u3044\u307e\u3059\u3002 <code>INSERT-SELECT<\/code>\u30de\u30eb\u30c1CTE\u5909\u63db\u3001\u30d3\u30e5\u30fc\u30c1\u30a7\u30fc\u30f3\u3001\u52d5\u7684SQL\u3092\u4f7f\u7528\u3057\u305f\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3001dbt\u30e2\u30c7\u30eb\u30c1\u30a7\u30fc\u30f3\u3001\u304a\u3088\u3073\u30af\u30ed\u30b9\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9ETL\u30d5\u30ed\u30fc\u306a\u3069\u3001\u3055\u307e\u3056\u307e\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u5404\u4f8b\u3067\u306fSQL\u6587\u3092\u793a\u3057\u3001\u305d\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u30ea\u30cd\u30fc\u30b8\u30b0\u30e9\u30d5\u304c\u3069\u306e\u3088\u3046\u306b\u751f\u6210\u3055\u308c\u308b\u304b\u3092\u6b63\u78ba\u306b\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained\" style=\"background-color:#eef7fb;padding-top:24px;padding-bottom:24px\"><div class=\"wp-block-group__inner-container\">\n\n<p><strong>\u3053\u306e\u30da\u30fc\u30b8\u306b\u63b2\u8f09\u3055\u308c\u3066\u3044\u308b\u4f8b\u306f\u3059\u3079\u3066\u518d\u73fe\u53ef\u80fd\u3067\u3059\u3002<\/strong> SQL \u3092\u8cbc\u308a\u4ed8\u3051\u308b <a href=\"https:\/\/sqlflow.gudusoft.com\/?utm_source=gudusoft&amp;utm_medium=website&amp;utm_campaign=data-lineage-examples\" target=\"_blank\" rel=\"noreferrer noopener\">\u7121\u6599\u306eSQLFlow\u7cfb\u7d71\u53ef\u8996\u5316\u30c4\u30fc\u30eb<\/a> \u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306b\u8aac\u660e\u3059\u308b\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306a\u56f3\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u3053\u308c\u3089\u306e\u4f8b\u6587\u306e\u8aad\u307f\u65b9<\/h2>\n\n\n\n<p>\u5404\u7cfb\u7d71\u56f3\u306b\u306f2\u7a2e\u985e\u306e\u8fba\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002 <strong>\u76f4\u63a5<\/strong> \u30a8\u30c3\u30b8\u3068\u306f\u3001\u30c7\u30fc\u30bf\u304c\u7269\u7406\u7684\u306b\u30bd\u30fc\u30b9\u5217\u304b\u3089\u30bf\u30fc\u30b2\u30c3\u30c8\u5217\u3078\u6d41\u308c\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3001\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u95a2\u6570\u3084\u96c6\u8a08\u95a2\u6570\u3092\u4ecb\u3057\u3066\u6d41\u308c\u308b\u3002 <strong>\u9593\u63a5\u7684<\/strong> \u30a8\u30c3\u30b8\u3068\u306f\u3001\u5217\u304c\u7d50\u679c\u306b\u7740\u5730\u3059\u308b\u3053\u3068\u306a\u304f\u7d50\u679c\u3092\u5f62\u6210\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002\u5217\u306f\u3001 <code>\u3069\u3053<\/code>, <code>\u53c2\u52a0\u3059\u308b<\/code>\u3001 \u3068 <code>\u30b0\u30eb\u30fc\u30d7\u5206\u3051<\/code> \u6761\u9805\u3002\u9593\u63a5\u7684\u306a\u30a8\u30c3\u30b8\u3092\u898b\u843d\u3068\u3059\u3068\u3001\u5f71\u97ff\u5206\u6790\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u30d5\u30a3\u30eb\u30bf\u30fc\u5217\u3092\u524a\u9664\u3059\u308b\u3068\u3001\u9078\u629e\u3057\u305f\u5217\u3092\u524a\u9664\u3059\u308b\u306e\u3068\u540c\u69d8\u306b\u30ec\u30dd\u30fc\u30c8\u304c\u58ca\u308c\u3066\u3057\u307e\u3046\u304b\u3089\u3067\u3059\u3002\u3053\u308c\u3089\u306e\u7528\u8a9e\u304c\u521d\u3081\u3066\u306e\u5834\u5408\u306f\u3001 <a href=\"https:\/\/www.gudusoft.com\/jp\/%e3%83%87%e3%83%bc%e3%82%bf%e7%b3%bb%e7%b5%b1%e3%81%a8%e3%81%af\/\">\u30c7\u30fc\u30bf\u30ea\u30cd\u30fc\u30b8\u3068\u306f\u4f55\u304b<\/a> \u3068 <a href=\"https:\/\/www.gudusoft.com\/jp\/%e5%88%97%e3%83%ac%e3%83%99%e3%83%ab%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%83%aa%e3%83%8d%e3%83%bc%e3%82%b8\/\">\u5217\u30ec\u30d9\u30eb\u306e\u7cfb\u7d71\u304c\u3069\u306e\u3088\u3046\u306b\u6a5f\u80fd\u3059\u308b\u304b<\/a>\u305d\u3057\u3066\u3001\u623b\u3063\u3066\u304d\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b1\uff1a\u5358\u7d14\u306aINSERT-SELECT\u30c7\u30fc\u30bf\u30ea\u30cd\u30fc\u30b8\u306e\u4f8b<\/h2>\n\n\n\n<p>\u7cfb\u7d71\u306b\u95a2\u3059\u308b\u8b70\u8ad6\u306e\u51fa\u767a\u70b9\u306f\u3001\u96c6\u8a08\u30c7\u30fc\u30bf\u3092\u8981\u7d04\u8868\u306b\u66f8\u304d\u8fbc\u30801\u3064\u306e\u8a18\u8ff0\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO sales_summary (region, total_amount) SELECT c.region, SUM(o.amount) FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.status = &#039;completed&#039; GROUP BY c.region;<\/code><\/pre>\n\n\n\n<p>\u7cfb\u7d71\u56f3\u306b\u306f 3 \u3064\u306e\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308a\u307e\u3059 (<code>\u6ce8\u6587<\/code>, <code>\u9867\u5ba2<\/code>, <code>\u58f2\u4e0a\u6982\u8981<\/code>\uff09\u305d\u3057\u3066\u3001\u3053\u308c\u3089\u306e\u5217\u30ec\u30d9\u30eb\u306e\u30a8\u30c3\u30b8\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5bfe\u8c61\u5217<\/th><th>\u30bd\u30fc\u30b9\u5217<\/th><th>\u30a8\u30c3\u30b8\u30bf\u30a4\u30d7<\/th><th>\u7d4c\u7531<\/th><\/tr><\/thead><tbody>\n<tr><td><code>\u58f2\u4e0a\u6982\u8981\u5730\u57df<\/code><\/td><td><code>\u9867\u5ba2\u5730\u57df<\/code><\/td><td>\u76f4\u63a5<\/td><td>\u30d7\u30ec\u30fc\u30f3\u30b3\u30d4\u30fc<\/td><\/tr>\n<tr><td><code>\u58f2\u4e0a\u6982\u8981.\u5408\u8a08\u91d1\u984d<\/code><\/td><td><code>\u6ce8\u6587\u6570<\/code><\/td><td>\u76f4\u63a5<\/td><td><code>\u548c\uff08\uff09<\/code><\/td><\/tr>\n<tr><td><code>\u58f2\u4e0a\u6982\u8981\u3002*<\/code><\/td><td><code>\u6ce8\u6587\u72b6\u6cc1<\/code><\/td><td>\u9593\u63a5\u7684<\/td><td><code>\u3069\u3053<\/code> \u30d5\u30a3\u30eb\u30bf\u30fc<\/td><\/tr>\n<tr><td><code>\u58f2\u4e0a\u6982\u8981\u3002*<\/code><\/td><td><code>\u6ce8\u6587\u306e\u9867\u5ba2ID<\/code>, <code>\u9867\u5ba2ID<\/code><\/td><td>\u9593\u63a5\u7684<\/td><td><code>\u53c2\u52a0\u3059\u308b<\/code> \u72b6\u614b<\/td><\/tr>\n<\/tbody><\/table><\/figure>\n\n\n\n<p>\u30b0\u30e9\u30d5\u304c\u65e2\u306b\u793a\u3057\u3066\u3044\u308b\u3053\u3068\u3067\u3001\u8868\u30ec\u30d9\u30eb\u306e\u30d3\u30e5\u30fc\u3067\u306f\u793a\u3055\u308c\u306a\u3044\u70b9\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002 <code>\u9867\u5ba2\u30e1\u30fc\u30eb<\/code> \u305d\u3057\u3066\u3001\u624b\u3064\u304b\u305a\u306e\u4ed6\u306e\u3059\u3079\u3066\u306e\u30b3\u30e9\u30e0\u306f\u3053\u3053\u3067\u306f\u4f55\u306e\u5f79\u5272\u3082\u679c\u305f\u3055\u305a\u3001 <code>\u6ce8\u6587\u72b6\u6cc1<\/code> \u51fa\u529b\u306b\u306f\u8868\u793a\u3055\u308c\u306a\u304f\u3066\u3082\u3001\u305d\u308c\u306f\u91cd\u8981\u306a\u610f\u5473\u3092\u6301\u3061\u307e\u3059\u3002\u591a\u304f\u306e\u7cfb\u7d71\u8ffd\u8de1\u30c4\u30fc\u30eb\u306f\u6700\u5f8c\u306e\u6bb5\u968e\u3092\u5b8c\u5168\u306b\u7701\u7565\u3057\u307e\u3059\u304c\u3001SQLFlow\u306f\u76f4\u63a5\u7684\u306a\u7cfb\u7d71\u3068\u9593\u63a5\u7684\u306a\u7cfb\u7d71\u3092\u3001\u5207\u308a\u66ff\u3048\u53ef\u80fd\u306a\u5225\u3005\u306e\u95a2\u4fc2\u30bf\u30a4\u30d7\u3068\u3057\u3066\u30e2\u30c7\u30eb\u5316\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b2\uff1a\u8907\u6570CTE\u5909\u63db<\/h2>\n\n\n\n<p>CTE\u306f\u3001\u624b\u63cf\u304d\u306e\u7cfb\u7d71\u56f3\u304c\u9069\u7528\u3055\u308c\u308b\u90e8\u5206\u3067\u3059\u3002\u306a\u305c\u306a\u3089\u3001\u5404CTE\u306f\u3001\u30b0\u30e9\u30d5\u304c\u5143\u306e\u30bd\u30fc\u30b9\u3092\u898b\u5931\u3046\u3053\u3068\u306a\u304f\u901a\u904e\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u4e00\u6642\u7684\u306a\u95a2\u4fc2\u3060\u304b\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WITH daily AS ( SELECT order_date, customer_id, SUM(amount) AS day_total FROM orders GROUP BY order_date, customer_id ), ranked AS ( SELECT customer_id, day_total, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY day_total DESC) AS rn FROM daily ) SELECT customer_id, day_total AS best_day_revenue FROM ranking WHERE rn = 1;<\/code><\/pre>\n\n\n\n<p>\u7cfb\u7d71\u56f3\u306f <code>\u6bce\u65e5<\/code> \u3068 <code>\u30e9\u30f3\u30ad\u30f3\u30b0<\/code> \u4e2d\u9593\u30ce\u30fc\u30c9\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u305f\u3081\u3001\u5bfe\u8c61\u3068\u306a\u308b\u5217\u306e\u5b8c\u5168\u306a\u30d1\u30b9\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002 <code>\u6ce8\u6587\u6570<\/code> \u2192 <code>\u548c\uff08\uff09<\/code> \u2192 <code>\u65e5\u5225\u5408\u8a08<\/code> \u2192 <code>\u30e9\u30f3\u30af\u4ed8\u3051\u3055\u308c\u305f\u65e5\u6570<\/code> \u2192 <code>\u30d9\u30b9\u30c8\u30c7\u30a4\u53ce\u76ca<\/code>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306f\u3001\u3088\u308a\u7e4a\u7d30\u306a\u9023\u9396\u3092\u4f5c\u308a\u51fa\u3057\u307e\u3059\u3002 <code>rn<\/code> \u306f\u4ee5\u4e0b\u304b\u3089\u8a08\u7b97\u3055\u308c\u307e\u3059 <code>\u9867\u5ba2ID<\/code> \uff08\u5206\u5272\uff09\u3068 <code>\u65e5\u5408\u8a08<\/code> \uff08\u6ce8\u6587\uff09\u305d\u3057\u3066 <code>\u3053\u3053\u3067\u3001rn = 1<\/code> \u4f5c\u308b <code>rn<\/code> \u3059\u3079\u3066\u306e\u51fa\u529b\u5217\u3078\u306e\u9593\u63a5\u7684\u306a\u5165\u529b\u3067\u3059\u3002 <code>\u6ce8\u6587\u6570<\/code> \u5f71\u97ff <code>\u30d9\u30b9\u30c8\u30c7\u30a4\u53ce\u76ca<\/code> 2\u3064\u306e\u7d4c\u8def\u304c\u3042\u308a\u307e\u3059\u30021\u3064\u306f\u5408\u8a08\u5024\u306b\u3088\u308b\u76f4\u63a5\u7684\u306a\u7d4c\u8def\u3001\u3082\u30461\u3064\u306f\u3069\u306e\u884c\u304c\u6b8b\u308b\u304b\u3092\u6c7a\u5b9a\u3059\u308b\u30e9\u30f3\u30ad\u30f3\u30b0\u306b\u3088\u308b\u9593\u63a5\u7684\u306a\u7d4c\u8def\u3067\u3059\u3002\u5217\u540d\u306e\u307f\u3092\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u3059\u308b\u30ea\u30be\u30eb\u30d0\u3067\u306f\u3001\u3053\u306e2\u756a\u76ee\u306e\u7d4c\u8def\u3092\u8a8d\u8b58\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b3\uff1a\u4e00\u9023\u306e\u898b\u89e3<\/h2>\n\n\n\n<p>\u30d3\u30e5\u30fc\u306f\u7a4d\u307f\u91cd\u306d\u3089\u308c\u308b\u3002\u6210\u719f\u3057\u305f\u30c7\u30fc\u30bf\u30a6\u30a7\u30a2\u30cf\u30a6\u30b9\u3067\u306f\u3001\u30ec\u30dd\u30fc\u30c8\u306f\u7269\u7406\u7684\u306a\u30c6\u30fc\u30d6\u30eb\u304b\u30893\u3064\u304b4\u3064\u306e\u30d3\u30e5\u30fc\u5b9a\u7fa9\u3092\u9694\u3066\u305f\u5834\u6240\u306b\u5b58\u5728\u3059\u308b\u3053\u3068\u304c\u591a\u304f\u3001\u300c\u3053\u306e\u6570\u5024\u306f\u5b9f\u969b\u306b\u306f\u3069\u3053\u304b\u3089\u6765\u305f\u306e\u304b\uff1f\u300d\u3068\u3044\u3046\u7591\u554f\u3092\u89e3\u660e\u3059\u308b\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30c1\u30a7\u30fc\u30f3\u5168\u4f53\u3092\u8fbf\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE VIEW v_active_customers AS SELECT id, name, email FROM customers WHERE status = &#039;active&#039;; CREATE VIEW v_customer_revenue AS SELECT a.id, a.name, SUM(o.amount) AS revenue FROM v_active_customers a JOIN orders o ON o.customer_id = a.id GROUP BY a.id, a.name;<\/code><\/pre>\n\n\n\n<p>\u30b0\u30e9\u30d5\u306f <code>v_customer_revenue.revenue<\/code> \u30d3\u30e5\u30fc\u5883\u754c\u3092\u305f\u3069\u3063\u3066\u623b\u308b <code>\u6ce8\u6587\u6570<\/code>\u3001 \u3068 <code>\u9867\u5ba2\u30b9\u30c6\u30fc\u30bf\u30b9<\/code> \u6700\u521d\u306e\u30d3\u30e5\u30fc\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u304b\u3089\u7d99\u627f\u3055\u308c\u305f\u9593\u63a5\u7684\u306a\u30a8\u30c3\u30b8\u3068\u3057\u3066\u63a5\u7d9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u53cd\u5bfe\u65b9\u5411\u306b\u3082\u6709\u7528\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002 <code>v_active_customers.email<\/code> \u6700\u521d\u306e\u30d3\u30e5\u30fc\u3067\u9078\u629e\u3055\u308c\u307e\u3059\u304c\u3001\u4e0b\u6d41\u3067\u306f\u4f55\u3082\u6d88\u8cbb\u3055\u308c\u307e\u305b\u3093\u3002\u3053\u306e\u3088\u3046\u306a\u30c7\u30c3\u30c9\u30ab\u30e9\u30e0\u306f\u3001\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3084\u79fb\u884c\u306e\u524d\u306b\u898b\u3064\u3051\u3066\u304a\u304d\u305f\u3044\u3082\u306e\u3067\u3042\u308a\u3001\u30c6\u30fc\u30d6\u30eb\u30ec\u30d9\u30eb\u3067\u306f\u898b\u3048\u307e\u305b\u3093\u3002\u30d3\u30e5\u30fc\u5b9a\u7fa9\u3067\u3053\u308c\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408 <code>\u9078\u629e *<\/code>SQLFlow \u306f\u30b9\u30ad\u30fc\u30de\u306b\u5bfe\u3057\u3066\u30b9\u30bf\u30fc\u3092\u5c55\u958b\u3059\u308b\u305f\u3081\u3001\u7d99\u627f\u3055\u308c\u305f\u3059\u3079\u3066\u306e\u5217\u306f\u7269\u7406\u7684\u306a\u30bd\u30fc\u30b9\u306b\u89e3\u6c7a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b4\uff1a\u52d5\u7684SQL\u3092\u4f7f\u7528\u3057\u305f\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/h2>\n\n\n\n<p>\u3053\u308c\u306f\u3001\u5bfe\u8c61\u30c6\u30fc\u30d6\u30eb\u540d\u304c\u30b3\u30fc\u30c9\u5185\u306b\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3001\u30ea\u30cd\u30fc\u30b8\u30c4\u30fc\u30eb\u3092\u533a\u5225\u3059\u308b\u4f8b\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u3068\u52d5\u7684\u306b\u7d44\u307f\u7acb\u3066\u3089\u308c\u305f\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u7528\u3057\u3066\u6708\u6b21\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b SQL Server \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3067\u3059\u3002 <code>\u5165\u308c\u308b<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE PROCEDURE dbo.load_monthly_snapshot @month VARCHAR(7) AS BEGIN SELECT o.customer_id, SUM(o.amount) AS month_total INTO #monthly FROM dbo.orders o WHERE CONVERT(VARCHAR(7), o.order_date, 126) = @month GROUP BY o.customer_id; DECLARE @sql NVARCHAR(MAX) = N&#039;INSERT INTO dbo.snapshot_monthly (customer_id, month_total) &#039; + N&#039;SELECT customer_id, month_total FROM #monthly&#039;; EXEC sp_executesql @sql; END<\/code><\/pre>\n\n\n\n<p>\u6b63\u3057\u3044\u7cfb\u7d71\u56f3\u306f\u3001\u4ee5\u4e0b\u306e2\u3064\u306e\u969c\u5bb3\u3092\u4e57\u308a\u8d8a\u3048\u307e\u3059\u3002 <code>\u6ce8\u6587\u6570<\/code> \u2192 <code>\u548c\uff08\uff09<\/code> \u2192 <code>#\u6708\u9593.\u6708\u9593\u5408\u8a08<\/code> \u2192 <code>snapshot_monthly.month_total<\/code>\u3001 \u3068 <code>\u6ce8\u6587\u65e5<\/code> \u9593\u63a5\u7684\u306a\u30a8\u30c3\u30b8\u3068\u3057\u3066 <code>\u3069\u3053<\/code> \u6761\u9805\u3068 <code>@\u6708<\/code> \u305d\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u3078\u306e\u5165\u529b\u3068\u3057\u3066\u8ffd\u8de1\u3055\u308c\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3002\u305d\u3053\u306b\u5230\u9054\u3059\u308b\u306b\u306f\u3001\u5b9f\u969b\u306e T-SQL \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3 \u30d1\u30fc\u30b5\u30fc (\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 \u30b9\u30d7\u30ea\u30c3\u30bf\u30fc\u3067\u306f\u306a\u3044)\u3001\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u9593\u306e\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u306e\u8ffd\u8de1\u3001\u304a\u3088\u3073\u6e21\u3055\u308c\u305f SQL \u6587\u5b57\u5217\u306e\u89e3\u6c7a\u304c\u5fc5\u8981\u3067\u3059\u3002 <code>sp_executesql<\/code>. SQLFlow has dedicated procedural parsers for SQL Server T-SQL and Oracle PL\/SQL, resolves dynamic SQL inside procedures, and additionally renders a call graph of which procedures invoke which, so procedure-to-procedure lineage is visible too. Dynamic SQL is the most common blind spot in lineage tooling; if you evaluate any tool, test it with this pattern first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b5\uff1adbt\u30e2\u30c7\u30eb\u30c1\u30a7\u30fc\u30f3<\/h2>\n\n\n\n<p>dbt \u306f\u3001\u30e2\u30c7\u30eb\u30ec\u30d9\u30eb\u306e\u7cfb\u7d71\u60c5\u5831\u3092\u3059\u3050\u306b\u63d0\u4f9b\u3057\u307e\u3059 <code>ref()<\/code>\u3057\u304b\u3057\u3001\u8208\u5473\u6df1\u3044\u306e\u306f\u5217\u30ec\u30d9\u30eb\u306e\u554f\u984c\u3067\u3059\u3002\u3069\u306e\u30bd\u30fc\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3069\u306e\u30de\u30fc\u30c8\u5217\u306b\u4f9b\u7d66\u3055\u308c\u3001\u3069\u306e\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30ea\u30cd\u30fc\u30e0\u3092\u7d4c\u7531\u3059\u308b\u306e\u304b\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- models\/staging\/stg_orders.sql SELECT id AS order_id, customer_id, amount, status FROM {{ source(&#039;raw&#039;, &#039;orders&#039;) }} -- models\/marts\/fct_customer_revenue.sql SELECT customer_id, SUM(amount) AS lifetime_revenue FROM {{ ref(&#039;stg_orders&#039;) }} WHERE status = &#039;completed&#039; GROUP BY customer_id<\/code><\/pre>\n\n\n\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306edbt\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u3092SQLFlow\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u3068\u3001\u30b0\u30e9\u30d5\u304c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5316\u3055\u308c\u305f\u53c2\u7167\u3092\u5177\u4f53\u7684\u306a\u5217\u30c1\u30a7\u30fc\u30f3\u306b\u89e3\u6c7a\u3057\u307e\u3059\u3002 <code>\u751f\u306e\u6ce8\u6587\u6570<\/code> \u2192 <code>stg_orders.amount<\/code> \u2192 <code>\u548c\uff08\uff09<\/code> \u2192 <code>fct_\u9867\u5ba2\u53ce\u76ca.\u751f\u6daf\u53ce\u76ca<\/code>\u540d\u524d\u5909\u66f4\u306b\u3088\u308a <code>ID<\/code> \u2192 <code>\u6ce8\u6587ID<\/code> \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30db\u30c3\u30d7\u306b\u4fdd\u5b58\u3055\u308c\u3001 <code>\u72b6\u614b<\/code> \u30de\u30fc\u30c8\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u304b\u3089\u9593\u63a5\u7684\u306a\u30a8\u30c3\u30b8\u3068\u3057\u3066\u6e21\u3055\u308c\u307e\u3059\u3002\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u306f\u30e2\u30c7\u30eb\u3092\u305d\u308c\u3089\u304c\u69cb\u7bc9\u3059\u308b\u30a6\u30a7\u30a2\u30cf\u30a6\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u7d50\u3073\u4ed8\u3051\u308b\u305f\u3081\u3001\u540c\u3058\u30b0\u30e9\u30d5\u304cdbt\u3067\u7ba1\u7406\u3055\u308c\u308b\u30ea\u30cd\u30fc\u30b8\u3068\u3001dbt\u306e\u5916\u90e8\u3067\u305d\u308c\u3089\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u89e6\u308c\u308b\u4ed6\u306e\u3059\u3079\u3066\u306e\u3082\u306e\u3092\u8abf\u548c\u3055\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b6\uff1a\u30af\u30ed\u30b9\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9ETL<\/h2>\n\n\n\n<p>\u4e0d\u52d5\u7523\u306f\u8907\u6570\u306e\u30a8\u30f3\u30b8\u30f3\u306b\u307e\u305f\u304c\u3063\u3066\u5b58\u5728\u3057\u307e\u3059\u3002\u5178\u578b\u7684\u306a\u6d41\u308c\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002\u904b\u7528\u4e2d\u306eSQL Server\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u30af\u30e9\u30a6\u30c9\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u62bd\u51fa\u3055\u308c\u3001Snowflake\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u306b\u30ed\u30fc\u30c9\u3055\u308c\u3001\u5206\u6790\u30b9\u30ad\u30fc\u30de\u306b\u5909\u63db\u3055\u308c\u307e\u3059\u3002\u30ed\u30fc\u30c9\u3068\u5909\u63db\u306e\u90e8\u5206\u306f\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- Snowflake COPY INTO staging.orders_raw FROM @s3_extract\/orders\/; INSERT INTO analytics.fct_orders (order_id, customer_id, amount_usd) SELECT r.order_id, r.customer_id, r.amount * fx.rate FROM staging.orders_raw r JOIN staging.fx_rates fx ON fx.currency = r.currency;<\/code><\/pre>\n\n\n\n<p>Snowflake\u5074\u3067\u306f\u3001\u30b0\u30e9\u30d5\u306f <code>\u91d1\u984d\uff08\u7c73\u30c9\u30eb\uff09<\/code> 2 \u3064\u306e\u76f4\u63a5\u306e\u89aa\u3092\u6301\u3064\u8a08\u7b97\u5217\u3068\u3057\u3066\u3001 <code>orders_raw.amount<\/code> \u3068 <code>fx_rates.rate<\/code>\u7b97\u8853\u5f0f\u3067\u7d50\u5408\u3055\u308c\u3001\u30d7\u30e9\u30b9 <code>\u901a\u8ca8<\/code> \u7d50\u5408\u6761\u4ef6\u304b\u3089\u306e\u9593\u63a5\u7684\u306a\u30a8\u30c3\u30b8\u3068\u3057\u3066\u3002\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u5168\u4f53\u3092\u30ab\u30d0\u30fc\u3059\u308b\u305f\u3081\u306b\u3001SQLFlow \u306b\u306f\u3001\u305d\u308c\u305e\u308c\u72ec\u81ea\u306e\u30c0\u30a4\u30a2\u30ec\u30af\u30c8\u3067\u4e21\u5074\u3092\u4f9b\u7d66\u3057\u307e\u3059\u3002T-SQL \u62bd\u51fa\u30ed\u30b8\u30c3\u30af\u306f SQL Server \u30d1\u30fc\u30b5\u30fc\u3067\u89e3\u6790\u3055\u308c\u3001Snowflake \u30b9\u30af\u30ea\u30d7\u30c8\u306f Snowflake \u30d1\u30fc\u30b5\u30fc\u3067\u89e3\u6790\u3055\u308c\u307e\u3059\u3002\u30c0\u30a4\u30a2\u30ec\u30af\u30c8\u56fa\u6709\u306e\u30d1\u30fc\u30b5\u30fc\u306f\u5408\u8a08 39 \u500b\u3042\u308a\u307e\u3059\u3002\u30a8\u30f3\u30bf\u30fc\u30d7\u30e9\u30a4\u30ba\u5c55\u958b\u3067\u306f\u3001\u7d50\u679c\u306f\u6c38\u7d9a\u7684\u306a\u30ea\u30cd\u30fc\u30b8 \u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u683c\u7d0d\u3055\u308c\u3001100 \u3092\u8d85\u3048\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068 100 \u4e07\u3092\u8d85\u3048\u308b\u5217\u306e\u74b0\u5883\u3092\u30d0\u30c3\u30c1 \u30b9\u30ad\u30e3\u30f3\u3059\u308b\u305f\u3081\u3001\u30a8\u30f3\u30c9\u30c4\u30fc\u30a8\u30f3\u30c9\u306e SQL Server \u304b\u3089 Snowflake \u307e\u3067\u306e\u72b6\u6cc1\u304c 1 \u3064\u306e\u30b0\u30e9\u30d5\u306b\u8868\u793a\u3055\u308c\u3001DataHub\u3001Microsoft Purview\u3001\u307e\u305f\u306f OpenMetadata \u306b\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3053\u308c\u30896\u3064\u306e\u4f8b\u306b\u5171\u901a\u3059\u308b\u3082\u306e<\/h2>\n\n\n\n<p>\u4e0a\u8a18\u306e\u30b0\u30e9\u30d5\u306f\u3059\u3079\u3066\u3001SQL\u30c6\u30ad\u30b9\u30c8\u3068\u30b9\u30ad\u30fc\u30de\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u307f\u304b\u3089\u751f\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u304c\u3001\u3053\u306e\u624b\u6cd5\u306e\u6839\u5e79\u3067\u3059\u3002 <a href=\"https:\/\/www.gudusoft.com\/jp\/sql-data-lineage-tool\/\">SQL\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u30ea\u30cd\u30fc\u30b8<\/a>\u5909\u63db\u30ed\u30b8\u30c3\u30af\u306f\u65e2\u306bSQL\u306b\u5b58\u5728\u3059\u308b\u305f\u3081\u3001\u305d\u306eSQL\u306e\u9759\u7684\u89e3\u6790\u306b\u3088\u308a\u3001\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3082\u30af\u30a8\u30ea\u30ed\u30b0\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3082\u30c7\u30fc\u30bf\u306e\u884c\u3092\u8aad\u307f\u53d6\u308b\u3053\u3068\u3082\u306a\u304f\u3001\u30c7\u30fc\u30bf\u7cfb\u5217\u304c\u518d\u69cb\u7bc9\u3055\u308c\u307e\u3059\u3002\u4f8b\u306e\u9055\u3044\u306f\u3001\u5358\u4e00\u306eSQL\u304b\u3089\u89e3\u6790\u304c\u3069\u308c\u3060\u3051\u96e3\u3057\u304f\u306a\u308b\u304b\u3068\u3044\u3046\u70b9\u3060\u3051\u3067\u3059\u3002 <code>INSERT-SELECT<\/code> \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u5185\u3067\u52d5\u7684SQL\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u4f8b<\/th><th>\u305d\u308c\u304c\u4f55\u3092\u935b\u3048\u308b\u304b<\/th><th>\u96e3\u3057\u3044\u3068\u3053\u308d<\/th><\/tr><\/thead><tbody>\n<tr><td>1. INSERT-SELECT<\/td><td>\u76f4\u63a5\u30a8\u30c3\u30b8\u3068\u9593\u63a5\u30a8\u30c3\u30b8<\/td><td>\u30e2\u30c7\u30ea\u30f3\u30b0 <code>\u3069\u3053<\/code>\/<code>\u53c2\u52a0\u3059\u308b<\/code> \u5217\u3092\u7cfb\u7d71\u3068\u3057\u3066<\/td><\/tr>\n<tr><td>2. \u30de\u30eb\u30c1CTE<\/td><td>\u4e2d\u9593\u95a2\u4fc2<\/td><td>\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u306e\u5165\u529b; \u30e9\u30f3\u30af\u306b\u57fa\u3065\u304f\u30d5\u30a3\u30eb\u30bf\u30d1\u30b9<\/td><\/tr>\n<tr><td>3. \u30d3\u30e5\u30fc\u30c1\u30a7\u30fc\u30f3<\/td><td>\u5165\u308c\u5b50\u306b\u306a\u3063\u305f\u5b9a\u7fa9<\/td><td>\u661f\u306e\u81a8\u5f35; \u30c7\u30c3\u30c9\u30b3\u30e9\u30e0\u306e\u767a\u898b<\/td><\/tr>\n<tr><td>4. \u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/td><td>\u624b\u7d9a\u304d\u30b3\u30fc\u30c9<\/td><td>\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u3068\u52d5\u7684SQL\u89e3\u6c7a<\/td><\/tr>\n<tr><td>5. dbt\u30c1\u30a7\u30fc\u30f3<\/td><td>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5316\u3055\u308c\u305fSQL<\/td><td>\u89e3\u6c7a\u3059\u308b <code>ref()<\/code>\/<code>\u30bd\u30fc\u30b9\uff08\uff09<\/code> \u5b9f\u7269<\/td><\/tr>\n<tr><td>6. \u30af\u30ed\u30b9\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9ETL<\/td><td>\u8907\u6570\u306e\u65b9\u8a00<\/td><td>\u30a8\u30f3\u30b8\u30f3\u3054\u3068\u306e\u30b0\u30e9\u30d5\u30921\u3064\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u7d71\u5408\u3059\u308b<\/td><\/tr>\n<\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u8cea\u554f<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c7\u30fc\u30bf\u7cfb\u7d71\u56f3\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f<\/h3>\n\n\n<p>\u30c7\u30fc\u30bf\u30ea\u30cd\u30fc\u30b8\u56f3\u306f\u3001\u30ce\u30fc\u30c9\u304c\u30c6\u30fc\u30d6\u30eb\u3001\u30d3\u30e5\u30fc\u3001\u307e\u305f\u306f\u5217\u3092\u8868\u3057\u3001\u30a8\u30c3\u30b8\u304cSQL\u5909\u63db\u3092\u901a\u3058\u3066\u305d\u308c\u3089\u306e\u9593\u3067\u30c7\u30fc\u30bf\u304c\u3069\u306e\u3088\u3046\u306b\u6d41\u308c\u308b\u304b\u3092\u793a\u3059\u6709\u5411\u30b0\u30e9\u30d5\u3067\u3059\u3002\u3053\u306e\u30da\u30fc\u30b8\u3067\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306a\u5217\u30ec\u30d9\u30eb\u306e\u56f3\u3067\u306f\u3001\u30bd\u30fc\u30b9\u5217\u3068\u30bf\u30fc\u30b2\u30c3\u30c8\u5217\u306e\u95a2\u4fc2\u3054\u3068\u306b1\u3064\u306e\u30a8\u30c3\u30b8\u304c\u63cf\u753b\u3055\u308c\u3001\u305d\u306e\u95a2\u4fc2\u3092\u4f5c\u6210\u3057\u305f\u95a2\u6570\u307e\u305f\u306f\u53e5\u304c\u6ce8\u91c8\u3068\u3057\u3066\u4ed8\u3051\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u3053\u308c\u3089\u306e\u4f8b\u3092\u81ea\u5206\u3067\u518d\u73fe\u3057\u3066\u3082\u3044\u3044\u3067\u3059\u304b\uff1f<\/h3>\n\n\n<p>\u306f\u3044\u3002\u4e0a\u8a18\u306eSQL\u30b9\u30cb\u30da\u30c3\u30c8\u306e\u3044\u305a\u308c\u304b\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u304f\u3060\u3055\u3044\u3002 <a href=\"https:\/\/sqlflow.gudusoft.com\/?utm_source=gudusoft&amp;utm_medium=website&amp;utm_campaign=data-lineage-examples\">\u7121\u6599\u306eSQLFlow\u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30b6\u30fc<\/a>\u8a72\u5f53\u3059\u308b\u65b9\u8a00\u3092\u9078\u629e\u3059\u308b\u3068\u3001\u6570\u79d2\u3067\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306a\u56f3\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u30af\u30e9\u30a6\u30c9\u7248\u306b\u306f\u7121\u6599\u30d7\u30e9\u30f3\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u76f4\u63a5\u7684\u306a\u8840\u7e01\u95a2\u4fc2\u3068\u9593\u63a5\u7684\u306a\u8840\u7e01\u95a2\u4fc2\u306e\u9055\u3044\u306f\u4f55\u3067\u3059\u304b\uff1f<\/h3>\n\n\n<p>\u76f4\u63a5\u7684\u306a\u30c7\u30fc\u30bf\u7cfb\u5217\u3068\u306f\u3001\u4f8b\u3048\u3070\u3001\u30bd\u30fc\u30b9\u5217\u304b\u3089\u30bf\u30fc\u30b2\u30c3\u30c8\u5217\u3078\u30c7\u30fc\u30bf\u304c\u6d41\u308c\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002 <code>SUM(orders.amount)<\/code> \u7d66\u990c <code>\u5408\u8a08\u91d1\u984d<\/code>\u9593\u63a5\u7684\u306a\u7cfb\u7d71\u3068\u306f\u3001\u5217\u304c\u7d50\u679c\u306b\u306f\u73fe\u308c\u306a\u3044\u304c\u7d50\u679c\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002 <code>\u3069\u3053<\/code> \u30d5\u30a3\u30eb\u30bf\u30fc\u307e\u305f\u306f <code>\u53c2\u52a0\u3059\u308b<\/code> \u91cd\u8981\u306a\u70b9\u3068\u3057\u3066\u3001SQLFlow\u306f\u4e21\u65b9\u3092\u500b\u5225\u306e\u5207\u308a\u66ff\u3048\u53ef\u80fd\u306a\u30a8\u30c3\u30b8\u30bf\u30a4\u30d7\u3068\u3057\u3066\u8ffd\u8de1\u3057\u307e\u3059\u304c\u3001\u307b\u3068\u3093\u3069\u306e\u30c4\u30fc\u30eb\u306f\u76f4\u63a5\u30d5\u30ed\u30fc\u306e\u307f\u3092\u6355\u6349\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3084\u52d5\u7684SQL\u304b\u3089\u7cfb\u7d71\u60c5\u5831\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u304b\uff1f<\/h3>\n\n\n<p>\u306f\u3044\u3001\u305f\u3060\u3057\u30af\u30a8\u30ea\u30d1\u30fc\u30b5\u30fc\u3060\u3051\u3067\u306a\u304f\u3001\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u30d1\u30fc\u30b5\u30fc\u304c\u5fc5\u8981\u3067\u3059\u3002SQLFlow\u306b\u306fOracle PL\/SQL\u3068SQL Server T-SQL\u5c02\u7528\u306e\u30d1\u30fc\u30b5\u30fc\u304c\u3042\u308a\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u3092\u4ecb\u3057\u305f\u30c7\u30fc\u30bf\u7cfb\u5217\u306e\u8ffd\u8de1\u3001\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u5185\u3067\u69cb\u7bc9\u3055\u308c\u305fSQL\u6587\u5b57\u5217\u306e\u89e3\u6c7a\u3001\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u9593\u306e\u547c\u3073\u51fa\u3057\u30b0\u30e9\u30d5\u306e\u63cf\u753b\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30c4\u30fc\u30eb\u306f\u3053\u308c\u3089\u306e\u4f8b\u306b\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u304b\uff1f<\/h3>\n\n\n<p>\u90e8\u5206\u7684\u306b\u3002\u56f3\u66f8\u9928\u306f <code>SQL Lineage<\/code> \u3068 <code>sqlglot<\/code> \u500b\u3005\u306e\u30af\u30a8\u30ea\u306e\u89e3\u6790\u306b\u975e\u5e38\u306b\u512a\u308c\u3066\u304a\u308a\u3001\u4f8b1\u3068\u4f8b2\u3082\u9069\u5207\u306b\u51e6\u7406\u3057\u307e\u3059\u3002\u30b3\u30df\u30c3\u30c8\u3059\u308b\u524d\u306b\u30c6\u30b9\u30c8\u3059\u308b\u4fa1\u5024\u306e\u3042\u308b\u4f8b\u306f\u3001\u4f8b4\uff5e6\u3067\u3059\u3002\u52d5\u7684SQL\u3092\u4f7f\u7528\u3057\u305f\u624b\u7d9a\u304d\u578b\u30b3\u30fc\u30c9\u3001\u5225\u306e\u30a8\u30c3\u30b8\u30bf\u30a4\u30d7\u3068\u3057\u3066\u306e\u9593\u63a5\u7684\u306a\u30c7\u30fc\u30bf\u7cfb\u5217\u3001\u8907\u6570\u306e\u65b9\u8a00\u304b\u3089\u306a\u308b\u74b0\u5883\u30921\u3064\u306e\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306a\u30b0\u30e9\u30d5\u306b\u7d71\u5408\u3059\u308b\u4f8b\u3067\u3059\u3002\u8a55\u4fa1\u5bfe\u8c61\u306e\u30c4\u30fc\u30eb\u3067\u3001\u6700\u3082\u8907\u96d1\u306a\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u5b9f\u884c\u3057\u3001\u51fa\u529b\u7d50\u679c\u3092\u6bd4\u8f03\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u3053\u308c\u3089\u306e\u4f8b\u306f\u3069\u306eSQL\u65b9\u8a00\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u304b\uff1f<\/h3>\n\n\n<p>SQLFlow\u306b\u306f\u3001Snowflake\u3001BigQuery\u3001Redshift\u3001Databricks\u3001Oracle\u3001SQL Server\u3001PostgreSQL\u3001MySQL\u3001Teradata\u3001Hive\u3001Spark SQL\u3001Trino\u306a\u3069\u300139\u7a2e\u985e\u306e\u8a00\u8a9e\u56fa\u6709\u306e\u30d1\u30fc\u30b5\u30fc\u304c\u540c\u68b1\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u6c4e\u7528SQL\u3001T-SQL\u3001dbt\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8SQL\u3001Snowflake\u69cb\u6587\u3092\u4f7f\u7528\u3057\u3066\u304a\u308a\u3001\u305d\u308c\u305e\u308c\u6c4e\u7528ANSI\u6587\u6cd5\u3067\u306f\u306a\u304f\u3001\u72ec\u81ea\u306e\u6587\u6cd5\u3067\u89e3\u6790\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-background is-layout-constrained\" style=\"background-color:#60d5f6;padding-top:32px;padding-bottom:32px\"><div class=\"wp-block-group__inner-container\">\n\n<h2 class=\"wp-block-heading\">\u72ec\u81ea\u306eSQL\u3092\u7cfb\u7d71\u56f3\u306b\u5909\u63db<\/h2>\n\n\n<p>\u30af\u30a8\u30ea\u3001\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3001\u307e\u305f\u306f\u30b9\u30af\u30ea\u30d7\u30c8\u5168\u4f53\u3092\u7121\u6599\u306e\u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30b6\u30fc\u306b\u8cbc\u308a\u4ed8\u3051\u308b\u3060\u3051\u3067\u3001\u6570\u79d2\u3067\u5217\u30ec\u30d9\u30eb\u306e\u30b0\u30e9\u30d5\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u591a\u6570\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u904b\u7528\u3055\u308c\u3066\u3044\u308b\u4f01\u696d\u5411\u3051\u306b\u306f\u3001\u30a8\u30f3\u30bf\u30fc\u30d7\u30e9\u30a4\u30ba\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u3064\u3044\u3066\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n<div class=\"wp-block-buttons is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/sqlflow.gudusoft.com\/?utm_source=gudusoft&amp;utm_medium=website&amp;utm_campaign=data-lineage-examples\" target=\"_blank\" rel=\"noreferrer noopener\">SQLFlow\u3092\u7121\u6599\u3067\u304a\u8a66\u3057\u304f\u3060\u3055\u3044<\/a><\/div>\n\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/www.gudusoft.com\/jp\/%e3%82%b3%e3%83%b3%e3%82%bf%e3%82%af%e3%83%88\/\">\u30a8\u30f3\u30bf\u30fc\u30d7\u30e9\u30a4\u30ba\u5411\u3051\u30c7\u30e2\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b<\/a><\/div>\n<\/div>\n\n<\/div><\/div>\n\n\n\n<script type=\"application\/ld+json\">{\n    \"@context\": \"https:\\\/\\\/schema.org\",\n    \"@graph\": [\n        {\n            \"@type\": \"TechArticle\",\n            \"headline\": \"Data Lineage Examples: 6 Real Scenarios with SQL and Diagrams\",\n            \"description\": \"Six worked data lineage examples with real SQL: INSERT-SELECT, multi-CTE transforms, view chains, stored procedures with dynamic SQL, dbt model chains, and cross-database ETL, each with the column-level lineage graph explained.\",\n            \"author\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Gudu Software\",\n                \"url\": \"https:\\\/\\\/www.gudusoft.com\\\/\"\n            },\n            \"publisher\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Gudu Software\",\n                \"url\": \"https:\\\/\\\/www.gudusoft.com\\\/\"\n            }\n        },\n        {\n            \"@type\": \"FAQPage\",\n            \"mainEntity\": [\n                {\n                    \"@type\": \"Question\",\n                    \"name\": \"What is a data lineage diagram?\",\n                    \"acceptedAnswer\": {\n                        \"@type\": \"Answer\",\n                        \"text\": \"A data lineage diagram is a directed graph in which nodes are tables, views, or columns and edges show how data flows between them through SQL transformations. Column-level diagrams draw one edge per source-column-to-target-column relationship, annotated with the function or clause that created it.\"\n                    }\n                },\n                {\n                    \"@type\": \"Question\",\n                    \"name\": \"Can I reproduce these examples myself?\",\n                    \"acceptedAnswer\": {\n                        \"@type\": \"Answer\",\n                        \"text\": \"Yes. Paste any of the SQL snippets into the free SQLFlow visualizer at sqlflow.gudusoft.com, pick the matching dialect, and the interactive diagram appears in seconds. The cloud edition has a free tier.\"\n                    }\n                },\n                {\n                    \"@type\": \"Question\",\n                    \"name\": \"What is the difference between direct and indirect lineage?\",\n                    \"acceptedAnswer\": {\n                        \"@type\": \"Answer\",\n                        \"text\": \"Direct lineage means data flows from a source column into a target column, for example SUM(orders.amount) feeding total_amount. Indirect lineage means a column influences the result without appearing in it, such as a WHERE filter or JOIN key. SQLFlow tracks both as separate, toggleable edge types.\"\n                    }\n                },\n                {\n                    \"@type\": \"Question\",\n                    \"name\": \"Can lineage be extracted from stored procedures and dynamic SQL?\",\n                    \"acceptedAnswer\": {\n                        \"@type\": \"Answer\",\n                        \"text\": \"Yes, but it needs a procedural parser. SQLFlow has dedicated parsers for Oracle PL\\\/SQL and SQL Server T-SQL, traces lineage through parameters and temp tables, resolves dynamic SQL built inside procedures, and draws the procedure-to-procedure call graph.\"\n                    }\n                },\n                {\n                    \"@type\": \"Question\",\n                    \"name\": \"Do open-source tools handle these examples?\",\n                    \"acceptedAnswer\": {\n                        \"@type\": \"Answer\",\n                        \"text\": \"Partially. Libraries like sqllineage and sqlglot parse individual queries well and handle simple INSERT-SELECT and CTE cases. The examples worth testing before you commit involve procedural code with dynamic SQL, indirect lineage as a separate edge type, and stitching a multi-dialect estate into one interactive graph.\"\n                    }\n                },\n                {\n                    \"@type\": \"Question\",\n                    \"name\": \"Which SQL dialects do these examples work with?\",\n                    \"acceptedAnswer\": {\n                        \"@type\": \"Answer\",\n                        \"text\": \"SQLFlow ships 39 dialect-specific parsers, including Snowflake, BigQuery, Redshift, Databricks, Oracle, SQL Server, PostgreSQL, MySQL, Teradata, Hive, Spark SQL, and Trino. Each dialect is parsed by its own grammar rather than a generic ANSI one.\"\n                    }\n                }\n            ]\n        }\n    ]\n}<\/script>","protected":false},"excerpt":{"rendered":"<p>A data lineage example shows, for a concrete piece of SQL, which source tables and columns feed which output columns, and through which transformations the data passes along the way. The six worked examples below cover the situations data engineers actually hit: a plain INSERT-SELECT, a multi-CTE transform, a chain of views, a stored procedure with dynamic SQL, a dbt model chain, and a cross-database ETL flow. Each example gives the SQL, then describes exactly what the lineage graph looks like for it. Every example on this page is reproducible: paste the SQL into the free SQLFlow lineage visualizer and\u2026<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"_links":{"self":[{"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/pages\/6748"}],"collection":[{"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/comments?post=6748"}],"version-history":[{"count":0,"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/pages\/6748\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gudusoft.com\/jp\/wp-json\/wp\/v2\/media?parent=6748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}