提交线下数据质量评估

This commit is contained in:
2025-10-23 19:59:04 +08:00
parent aa061fb78e
commit 852d54d03c

View File

@@ -139,3 +139,50 @@ 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;
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."门店性质"