From 852d54d03c409f042a6916dff8c902c5fb120911 Mon Sep 17 00:00:00 2001 From: zhumr Date: Thu, 23 Oct 2025 19:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=BA=BF=E4=B8=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=B4=A8=E9=87=8F=E8=AF=84=E4=BC=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../附件/2 执行SQL/CAATS-01-03 数据质量评估.txt | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/底稿/附件/2 执行SQL/CAATS-01-03 数据质量评估.txt b/底稿/附件/2 执行SQL/CAATS-01-03 数据质量评估.txt index eef1c9c..137b401 100644 --- a/底稿/附件/2 执行SQL/CAATS-01-03 数据质量评估.txt +++ b/底稿/附件/2 执行SQL/CAATS-01-03 数据质量评估.txt @@ -138,4 +138,51 @@ GROUP BY a.perYear, a.brandCode ORDER BY a.perYear; SQL6: SELECT SUBSTR(sale_date, 1, 4),brand_code, SUM(goods_amt) FROM custom_offline_sale_return_local cosrl WHERE SUBSTR(sale_date, 1, 10) >= '2024-05-01' AND SUBSTR(sale_date, 1, 10) <= '2025-06-30' AND brand_code IN ('SBZ', 'JXH') -GROUP BY SUBSTR(sale_date, 1, 4), brand_code; \ No newline at end of file +GROUP BY SUBSTR(sale_date, 1, 4), brand_code; + +SQL7: +SELECT + a."年份", + a."门店性质", + a."净销售金额", + b.settle_year AS "结算年份", + b.store_nature AS "门店性质(海澜提供)", + b.retail_amt AS "零售金额", + b.settle_amt AS "结算金额", + b.retail_amt - a."净销售金额" AS "差异" +FROM +( +SELECT + toYear(a.sale_time) AS "年份", + CASE + WHEN b.store_nature <> '' THEN b.store_nature + WHEN b.store_nature = '' THEN c.store_nature + END AS "门店性质", + SUM(a.goods_amt) AS "净销售金额" +FROM custom_offline_sale_return_local a +LEFT JOIN( + SELECT + store_code, + store_nature, + `year` AS period + FROM + custom_store_nature_all_local csnal + WHERE + source_table = 'store' +)b +ON a.store_code = b.store_code AND toString(toYear(a.sale_time)) = b.period +LEFT JOIN( + SELECT + store_code, + MIN(store_nature) AS store_nature + FROM + custom_store_nature_all_local csnal + GROUP BY store_code +)c +ON a.store_code = c.store_code +WHERE a.brand_code <>'SBZ' +AND a.brand_code <> 'JXH' +GROUP BY "年份","门店性质" +) a +LEFT JOIN dwd_storesettlement_hkaudit_settle_amt_mt b on toString(a."年份")=b.settle_year AND a."门店性质"=b.store_nature +ORDER BY a."年份",a."门店性质" \ No newline at end of file