3036 lines
132 KiB
Plaintext
3036 lines
132 KiB
Plaintext
SQL1:
|
||
SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name_t) AS "店铺名称",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量",
|
||
ROUND((SUM(real_goods_amt_t) + SUM(order_freight_amt_t)) / COUNT(DISTINCT platform_order_no), 2) AS "订单均价(元)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), store_code
|
||
ORDER BY SUBSTR(order_time_t, 1, 4), SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL2:
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name) AS "店铺名称",
|
||
SUM(goods_amt) AS "销售金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
ORDER BY SUBSTR(order_time, 1, 4), SUM(goods_amt) DESC;
|
||
|
||
SQL3:
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name_t) AS "店铺名称",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量",
|
||
ROUND((SUM(real_goods_amt_t) + SUM(order_freight_amt_t)) / COUNT(DISTINCT platform_order_no), 2) AS "订单均价(元)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
ORDER BY SUBSTR(mgclear_time_t, 1, 4), SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL4:
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name) AS "店铺名称",
|
||
SUM(goods_amt) AS "销售金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
ORDER BY SUBSTR(mgclear_time, 1, 4), SUM(goods_amt) DESC;
|
||
|
||
SQL5:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
MAX(t1.storeName) AS "店铺名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t1.orderFreightAmt) AS "运费金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t2.returnFreightAmt) AS "退货运费金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(store_name_t) AS storeName,
|
||
platform_order_no,
|
||
MIN(order_time_t) AS orderTime,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT store_code, platform_order_no,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.store_code
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL6:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name AS "店铺名称",
|
||
t1.sale_amount AS "销售金额(元)",
|
||
t2.return_amount AS "退货金额(元)",
|
||
t1.sale_amount + t2.return_amount AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(store_name) AS store_name,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
ORDER BY t1.perYear, (t1.sale_amount + t2.return_amount) DESC;
|
||
|
||
SQL7:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
MAX(t1.storeName) AS "店铺名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(store_name) AS storeName,
|
||
platform_order_no,
|
||
MIN(order_time) AS orderTime,
|
||
SUM(real_goods_amt_order_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.store_code
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL8:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
MAX(t1.storeName) AS "店铺名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t1.orderFreightAmt) AS "运费金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t2.returnFreightAmt) AS "退货运费金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(store_name_t) AS storeName,
|
||
platform_order_no,
|
||
MIN(order_time_t) AS orderTime,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT store_code, platform_order_no,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.store_code
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL9:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name AS "店铺名称",
|
||
t1.sale_amount AS "销售金额(元)",
|
||
t2.return_amount AS "退货金额(元)",
|
||
t1.sale_amount + t2.return_amount AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(store_name) AS store_name,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
ORDER BY t1.perYear, (t1.sale_amount + t2.return_amount) DESC;
|
||
|
||
SQL10:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
MAX(t1.storeName) AS "店铺名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(store_name) AS storeName,
|
||
platform_order_no,
|
||
MIN(order_time) AS orderTime,
|
||
SUM(real_goods_amt_order_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.store_code
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL11:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
t1.storeName AS "店铺名称",
|
||
t1.goodsAmt AS "销售金额(元)",
|
||
t1.orderFreightAmt AS "运费金额(元)",
|
||
t2.returnGoodsAmt AS "退货金额(元)",
|
||
t2.returnFreightAmt AS "退货运费金额(元)",
|
||
t3.orderChangeAmt AS "发货调整金额(元)",
|
||
t1.goodsAmt + t1.orderFreightAmt + t2.returnGoodsAmt
|
||
+ t2.returnFreightAmt + t3.orderChangeAmt AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(store_name_t) AS storeName,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
LEFT JOIN (
|
||
SELECT SUBSTR(mgclear_time, 1, 4) AS perYear, store_code, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t3 ON t1.perYear = t3.perYear AND t1.store_code = t3.store_code
|
||
ORDER BY t1.perYear, t1.goodsAmt + t1.orderFreightAmt + t2.returnGoodsAmt
|
||
+ t2.returnFreightAmt + t3.orderChangeAmt DESC;
|
||
|
||
SQL12:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name AS "店铺名称",
|
||
t1.sale_amount AS "销售金额(元)",
|
||
t2.return_amount AS "退货金额(元)",
|
||
t1.sale_amount + t2.return_amount AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(store_name) AS store_name,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
ORDER BY t1.perYear, (t1.sale_amount + t2.return_amount) DESC;
|
||
|
||
SQL13:
|
||
SELECT
|
||
SUBSTR(t1.mgclearTime, 1, 4) AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
MAX(t1.storeName) AS "店铺名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(store_name) AS storeName,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclearTime,
|
||
SUM(real_goods_amt_mgclear_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.mgclearTime, 1, 4), t1.store_code
|
||
ORDER BY SUBSTR(t1.mgclearTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL14:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
t1.storeName AS "店铺名称",
|
||
t1.goodsAmt AS "销售金额(元)",
|
||
t1.orderFreightAmt AS "运费金额(元)",
|
||
t2.returnGoodsAmt AS "退货金额(元)",
|
||
t2.returnFreightAmt AS "退货运费金额(元)",
|
||
t3.orderChangeAmt AS "发货调整金额(元)",
|
||
t1.goodsAmt + t1.orderFreightAmt + t2.returnGoodsAmt
|
||
+ t2.returnFreightAmt + t3.orderChangeAmt AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(store_name_t) AS storeName,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
LEFT JOIN (
|
||
SELECT SUBSTR(mgclear_time, 1, 4) AS perYear, store_code, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t3 ON t1.perYear = t3.perYear AND t1.store_code = t3.store_code
|
||
ORDER BY t1.perYear, t1.goodsAmt + t1.orderFreightAmt + t2.returnGoodsAmt
|
||
+ t2.returnFreightAmt + t3.orderChangeAmt DESC;
|
||
|
||
SQL15:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name AS "店铺名称",
|
||
t1.sale_amount AS "销售金额(元)",
|
||
t2.return_amount AS "退货金额(元)",
|
||
t1.sale_amount + t2.return_amount AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(store_name) AS store_name,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
ORDER BY t1.perYear, (t1.sale_amount + t2.return_amount) DESC;
|
||
|
||
SQL16:
|
||
SELECT
|
||
SUBSTR(t1.mgclearTime, 1, 4) AS "年份",
|
||
t1.store_code AS "店铺编码",
|
||
MAX(t1.storeName) AS "店铺名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(store_name) AS storeName,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclearTime,
|
||
SUM(real_goods_amt_mgclear_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.mgclearTime, 1, 4), t1.store_code
|
||
ORDER BY SUBSTR(t1.mgclearTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL17:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.brandCode AS "品牌编码",
|
||
CASE WHEN t1.brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN t1.brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN t1.brandCode = 'NCL' THEN '男生女生'
|
||
WHEN t1.brandCode = 'YEO' THEN '英式'
|
||
WHEN t1.brandCode = 'OVV' THEN 'OVV'
|
||
WHEN t1.brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN t1.brandCode = 'QIT' THEN '其他'
|
||
WHEN t1.brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN t1.brandCode = 'AEX' THEN 'AEX'
|
||
WHEN t1.brandCode = 'BES' THEN '海一家'
|
||
WHEN t1.brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN t1.brandCode = 'HED' THEN 'HEAD'
|
||
WHEN t1.brandCode = 'VPG' THEN 'VPG'
|
||
WHEN t1.brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN t1.brandCode = 'JXH' THEN '京新海'
|
||
WHEN t1.brandCode = 'LHB' THEN '企业购'
|
||
WHEN t1.brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN t1.brandCode = 'DIY' THEN '致加'
|
||
WHEN t1.brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE t1.brandCode
|
||
END AS "品牌名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t1.orderFreightAmt) AS "运费金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t2.returnFreightAmt) AS "退货运费金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(brand_code_t) AS brandCode,
|
||
platform_order_no,
|
||
MIN(order_time_t) AS orderTime,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brand_code_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT store_code, platform_order_no,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.brandCode
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL18:
|
||
SELECT
|
||
perYear AS "年份",
|
||
brand_code AS "品牌编码",
|
||
CASE WHEN brand_code = 'HLA' THEN '海澜之家'
|
||
WHEN brand_code = 'HJS' THEN '黑鲸'
|
||
WHEN brand_code = 'NCL' THEN '男生女生'
|
||
WHEN brand_code = 'YEO' THEN '英式'
|
||
WHEN brand_code = 'OVV' THEN 'OVV'
|
||
WHEN brand_code = 'HLM' THEN '海澜优选'
|
||
WHEN brand_code = 'QIT' THEN '其他'
|
||
WHEN brand_code = 'SBZ' THEN '斯搏兹'
|
||
WHEN brand_code = 'AEX' THEN 'AEX'
|
||
WHEN brand_code = 'BES' THEN '海一家'
|
||
WHEN brand_code = 'HGS' THEN '蓝鲸'
|
||
WHEN brand_code = 'HED' THEN 'HEAD'
|
||
WHEN brand_code = 'VPG' THEN 'VPG'
|
||
WHEN brand_code = 'HLP' THEN 'HLA PLUS'
|
||
WHEN brand_code = 'JXH' THEN '京新海'
|
||
WHEN brand_code = 'LHB' THEN '企业购'
|
||
WHEN brand_code = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN brand_code = 'DIY' THEN '致加'
|
||
WHEN brand_code = 'HEA' THEN 'HEAD AURA'
|
||
ELSE brand_code
|
||
END AS "品牌名称",
|
||
SUM(sale_amount) AS "销售金额(元)",
|
||
SUM(return_amount) AS "退货金额(元)",
|
||
SUM(sale_amount) + SUM(return_amount) AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
t1.perYear,
|
||
t1.brand_code,
|
||
t1.sale_amount,
|
||
t2.return_amount
|
||
FROM (SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(brand_code) AS brand_code,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
)
|
||
GROUP BY perYear, brand_code
|
||
ORDER BY perYear, (SUM(sale_amount) + SUM(return_amount)) DESC;
|
||
|
||
SQL19:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.brandCode AS "品牌编码",
|
||
CASE WHEN t1.brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN t1.brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN t1.brandCode = 'NCL' THEN '男生女生'
|
||
WHEN t1.brandCode = 'YEO' THEN '英式'
|
||
WHEN t1.brandCode = 'OVV' THEN 'OVV'
|
||
WHEN t1.brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN t1.brandCode = 'QIT' THEN '其他'
|
||
WHEN t1.brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN t1.brandCode = 'AEX' THEN 'AEX'
|
||
WHEN t1.brandCode = 'BES' THEN '海一家'
|
||
WHEN t1.brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN t1.brandCode = 'HED' THEN 'HEAD'
|
||
WHEN t1.brandCode = 'VPG' THEN 'VPG'
|
||
WHEN t1.brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN t1.brandCode = 'JXH' THEN '京新海'
|
||
WHEN t1.brandCode = 'LHB' THEN '企业购'
|
||
WHEN t1.brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN t1.brandCode = 'DIY' THEN '致加'
|
||
WHEN t1.brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE t1.brandCode
|
||
END AS "品牌名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brandCode,
|
||
platform_order_no,
|
||
MIN(order_time) AS orderTime,
|
||
SUM(real_goods_amt_order_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.brandCode
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL20:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.brandCode AS "品牌编码",
|
||
CASE WHEN t1.brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN t1.brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN t1.brandCode = 'NCL' THEN '男生女生'
|
||
WHEN t1.brandCode = 'YEO' THEN '英式'
|
||
WHEN t1.brandCode = 'OVV' THEN 'OVV'
|
||
WHEN t1.brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN t1.brandCode = 'QIT' THEN '其他'
|
||
WHEN t1.brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN t1.brandCode = 'AEX' THEN 'AEX'
|
||
WHEN t1.brandCode = 'BES' THEN '海一家'
|
||
WHEN t1.brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN t1.brandCode = 'HED' THEN 'HEAD'
|
||
WHEN t1.brandCode = 'VPG' THEN 'VPG'
|
||
WHEN t1.brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN t1.brandCode = 'JXH' THEN '京新海'
|
||
WHEN t1.brandCode = 'LHB' THEN '企业购'
|
||
WHEN t1.brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN t1.brandCode = 'DIY' THEN '致加'
|
||
WHEN t1.brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE t1.brandCode
|
||
END AS "品牌名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t1.orderFreightAmt) AS "运费金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t2.returnFreightAmt) AS "退货运费金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(brand_code_t) AS brandCode,
|
||
platform_order_no,
|
||
MIN(order_time_t) AS orderTime,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brand_code_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT store_code, platform_order_no,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.brandCode
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t1.orderFreightAmt) + SUM(t2.returnGoodsAmt)
|
||
+ SUM(t2.returnFreightAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL21:
|
||
SELECT
|
||
perYear AS "年份",
|
||
brand_code AS "品牌编码",
|
||
CASE WHEN brand_code = 'HLA' THEN '海澜之家'
|
||
WHEN brand_code = 'HJS' THEN '黑鲸'
|
||
WHEN brand_code = 'NCL' THEN '男生女生'
|
||
WHEN brand_code = 'YEO' THEN '英式'
|
||
WHEN brand_code = 'OVV' THEN 'OVV'
|
||
WHEN brand_code = 'HLM' THEN '海澜优选'
|
||
WHEN brand_code = 'QIT' THEN '其他'
|
||
WHEN brand_code = 'SBZ' THEN '斯搏兹'
|
||
WHEN brand_code = 'AEX' THEN 'AEX'
|
||
WHEN brand_code = 'BES' THEN '海一家'
|
||
WHEN brand_code = 'HGS' THEN '蓝鲸'
|
||
WHEN brand_code = 'HED' THEN 'HEAD'
|
||
WHEN brand_code = 'VPG' THEN 'VPG'
|
||
WHEN brand_code = 'HLP' THEN 'HLA PLUS'
|
||
WHEN brand_code = 'JXH' THEN '京新海'
|
||
WHEN brand_code = 'LHB' THEN '企业购'
|
||
WHEN brand_code = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN brand_code = 'DIY' THEN '致加'
|
||
WHEN brand_code = 'HEA' THEN 'HEAD AURA'
|
||
ELSE brand_code
|
||
END AS "品牌名称",
|
||
SUM(sale_amount) AS "销售金额(元)",
|
||
SUM(return_amount) AS "退货金额(元)",
|
||
SUM(sale_amount) + SUM(return_amount) AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
t1.perYear,
|
||
t1.brand_code,
|
||
t1.sale_amount,
|
||
t2.return_amount
|
||
FROM (SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(brand_code) AS brand_code,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
)
|
||
GROUP BY perYear, brand_code
|
||
ORDER BY perYear, (SUM(sale_amount) + SUM(return_amount)) DESC;
|
||
|
||
SQL22:
|
||
SELECT
|
||
SUBSTR(t1.orderTime, 1, 4) AS "年份",
|
||
t1.brandCode AS "品牌编码",
|
||
CASE WHEN t1.brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN t1.brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN t1.brandCode = 'NCL' THEN '男生女生'
|
||
WHEN t1.brandCode = 'YEO' THEN '英式'
|
||
WHEN t1.brandCode = 'OVV' THEN 'OVV'
|
||
WHEN t1.brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN t1.brandCode = 'QIT' THEN '其他'
|
||
WHEN t1.brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN t1.brandCode = 'AEX' THEN 'AEX'
|
||
WHEN t1.brandCode = 'BES' THEN '海一家'
|
||
WHEN t1.brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN t1.brandCode = 'HED' THEN 'HEAD'
|
||
WHEN t1.brandCode = 'VPG' THEN 'VPG'
|
||
WHEN t1.brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN t1.brandCode = 'JXH' THEN '京新海'
|
||
WHEN t1.brandCode = 'LHB' THEN '企业购'
|
||
WHEN t1.brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN t1.brandCode = 'DIY' THEN '致加'
|
||
WHEN t1.brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE t1.brandCode
|
||
END AS "品牌名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brandCode,
|
||
platform_order_no,
|
||
MIN(order_time) AS orderTime,
|
||
SUM(real_goods_amt_order_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM custom_online_sale_return_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM custom_online_sale_change_local
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.orderTime, 1, 4), t1.brandCode
|
||
ORDER BY SUBSTR(t1.orderTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL23:
|
||
SELECT
|
||
perYear AS "年份",
|
||
brandCode AS "品牌编码",
|
||
CASE WHEN brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN brandCode = 'NCL' THEN '男生女生'
|
||
WHEN brandCode = 'YEO' THEN '英式'
|
||
WHEN brandCode = 'OVV' THEN 'OVV'
|
||
WHEN brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN brandCode = 'QIT' THEN '其他'
|
||
WHEN brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN brandCode = 'AEX' THEN 'AEX'
|
||
WHEN brandCode = 'BES' THEN '海一家'
|
||
WHEN brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN brandCode = 'HED' THEN 'HEAD'
|
||
WHEN brandCode = 'VPG' THEN 'VPG'
|
||
WHEN brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN brandCode = 'JXH' THEN '京新海'
|
||
WHEN brandCode = 'LHB' THEN '企业购'
|
||
WHEN brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN brandCode = 'DIY' THEN '致加'
|
||
WHEN brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE brandCode
|
||
END AS "品牌名称",
|
||
SUM(goodsAmt) AS "销售金额(元)",
|
||
SUM(orderFreightAmt) AS "运费金额(元)",
|
||
SUM(returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(returnFreightAmt) AS "退货运费金额(元)",
|
||
SUM(orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(goodsAmt) + SUM(orderFreightAmt) + SUM(returnGoodsAmt)
|
||
+ SUM(returnFreightAmt) + SUM(orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
t1.perYear AS perYear,
|
||
t1.brand_code_t_t AS brandCode,
|
||
t1.goodsAmt AS goodsAmt,
|
||
t1.orderFreightAmt AS orderFreightAmt,
|
||
t2.returnFreightAmt AS returnFreightAmt,
|
||
t2.returnGoodsAmt AS returnGoodsAmt,
|
||
t3.orderChangeAmt AS orderChangeAmt
|
||
FROM (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(brand_code_t) AS brand_code_t_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brand_code_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
LEFT JOIN (
|
||
SELECT SUBSTR(mgclear_time, 1, 4) AS perYear, store_code, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t3 ON t1.perYear = t3.perYear AND t1.store_code = t3.store_code
|
||
) GROUP BY perYear, brandCode
|
||
ORDER BY perYear, SUM(goodsAmt) + SUM(orderFreightAmt) + SUM(returnGoodsAmt)
|
||
+ SUM(returnFreightAmt) + SUM(orderChangeAmt) DESC;
|
||
|
||
SQL24:
|
||
SELECT
|
||
perYear AS "年份",
|
||
brand_code AS "品牌编码",
|
||
CASE WHEN brand_code = 'HLA' THEN '海澜之家'
|
||
WHEN brand_code = 'HJS' THEN '黑鲸'
|
||
WHEN brand_code = 'NCL' THEN '男生女生'
|
||
WHEN brand_code = 'YEO' THEN '英式'
|
||
WHEN brand_code = 'OVV' THEN 'OVV'
|
||
WHEN brand_code = 'HLM' THEN '海澜优选'
|
||
WHEN brand_code = 'QIT' THEN '其他'
|
||
WHEN brand_code = 'SBZ' THEN '斯搏兹'
|
||
WHEN brand_code = 'AEX' THEN 'AEX'
|
||
WHEN brand_code = 'BES' THEN '海一家'
|
||
WHEN brand_code = 'HGS' THEN '蓝鲸'
|
||
WHEN brand_code = 'HED' THEN 'HEAD'
|
||
WHEN brand_code = 'VPG' THEN 'VPG'
|
||
WHEN brand_code = 'HLP' THEN 'HLA PLUS'
|
||
WHEN brand_code = 'JXH' THEN '京新海'
|
||
WHEN brand_code = 'LHB' THEN '企业购'
|
||
WHEN brand_code = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN brand_code = 'DIY' THEN '致加'
|
||
WHEN brand_code = 'HEA' THEN 'HEAD AURA'
|
||
ELSE brand_code
|
||
END AS "品牌名称",
|
||
SUM(sale_amount) AS "销售金额(元)",
|
||
SUM(return_amount) AS "退货金额(元)",
|
||
SUM(sale_amount) + SUM(return_amount) AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
t1.perYear,
|
||
t1.brand_code,
|
||
t1.sale_amount,
|
||
t2.return_amount
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(brand_code) AS brand_code,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
)
|
||
GROUP BY perYear, brand_code
|
||
ORDER BY perYear, (SUM(sale_amount) + SUM(return_amount)) DESC;
|
||
|
||
SQL25:
|
||
SELECT
|
||
SUBSTR(t1.mgclearTime, 1, 4) AS "年份",
|
||
t1.brandCode AS "店铺编码",
|
||
CASE WHEN t1.brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN t1.brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN t1.brandCode = 'NCL' THEN '男生女生'
|
||
WHEN t1.brandCode = 'YEO' THEN '英式'
|
||
WHEN t1.brandCode = 'OVV' THEN 'OVV'
|
||
WHEN t1.brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN t1.brandCode = 'QIT' THEN '其他'
|
||
WHEN t1.brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN t1.brandCode = 'AEX' THEN 'AEX'
|
||
WHEN t1.brandCode = 'BES' THEN '海一家'
|
||
WHEN t1.brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN t1.brandCode = 'HED' THEN 'HEAD'
|
||
WHEN t1.brandCode = 'VPG' THEN 'VPG'
|
||
WHEN t1.brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN t1.brandCode = 'JXH' THEN '京新海'
|
||
WHEN t1.brandCode = 'LHB' THEN '企业购'
|
||
WHEN t1.brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN t1.brandCode = 'DIY' THEN '致加'
|
||
WHEN t1.brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE t1.brandCode
|
||
END AS "品牌名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brandCode,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclearTime,
|
||
SUM(real_goods_amt_mgclear_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.mgclearTime, 1, 4), t1.brandCode
|
||
ORDER BY SUBSTR(t1.mgclearTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL26:
|
||
SELECT
|
||
perYear AS "年份",
|
||
brandCode AS "品牌编码",
|
||
CASE WHEN brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN brandCode = 'NCL' THEN '男生女生'
|
||
WHEN brandCode = 'YEO' THEN '英式'
|
||
WHEN brandCode = 'OVV' THEN 'OVV'
|
||
WHEN brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN brandCode = 'QIT' THEN '其他'
|
||
WHEN brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN brandCode = 'AEX' THEN 'AEX'
|
||
WHEN brandCode = 'BES' THEN '海一家'
|
||
WHEN brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN brandCode = 'HED' THEN 'HEAD'
|
||
WHEN brandCode = 'VPG' THEN 'VPG'
|
||
WHEN brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN brandCode = 'JXH' THEN '京新海'
|
||
WHEN brandCode = 'LHB' THEN '企业购'
|
||
WHEN brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN brandCode = 'DIY' THEN '致加'
|
||
WHEN brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE brandCode
|
||
END AS "品牌名称",
|
||
SUM(goodsAmt) AS "销售金额(元)",
|
||
SUM(orderFreightAmt) AS "运费金额(元)",
|
||
SUM(returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(returnFreightAmt) AS "退货运费金额(元)",
|
||
SUM(orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(goodsAmt) + SUM(orderFreightAmt) + SUM(returnGoodsAmt)
|
||
+ SUM(returnFreightAmt) + SUM(orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
t1.perYear AS perYear,
|
||
t1.brand_code_t_t AS brandCode,
|
||
t1.goodsAmt AS goodsAmt,
|
||
t1.orderFreightAmt AS orderFreightAmt,
|
||
t2.returnFreightAmt AS returnFreightAmt,
|
||
t2.returnGoodsAmt AS returnGoodsAmt,
|
||
t3.orderChangeAmt AS orderChangeAmt
|
||
FROM (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(brand_code_t) AS brand_code_t_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brand_code_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(return_freight_amt_t) AS returnFreightAmt,
|
||
SUM(real_return_goods_amt_t) AS returnGoodsAmt
|
||
FROM (SELECT
|
||
store_code,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
LEFT JOIN (
|
||
SELECT SUBSTR(mgclear_time, 1, 4) AS perYear, store_code, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t3 ON t1.perYear = t3.perYear AND t1.store_code = t3.store_code
|
||
) GROUP BY perYear, brandCode
|
||
ORDER BY perYear, SUM(goodsAmt) + SUM(orderFreightAmt) + SUM(returnGoodsAmt)
|
||
+ SUM(returnFreightAmt) + SUM(orderChangeAmt) DESC;
|
||
|
||
SQL27:
|
||
SELECT
|
||
perYear AS "年份",
|
||
brand_code AS "品牌编码",
|
||
CASE WHEN brand_code = 'HLA' THEN '海澜之家'
|
||
WHEN brand_code = 'HJS' THEN '黑鲸'
|
||
WHEN brand_code = 'NCL' THEN '男生女生'
|
||
WHEN brand_code = 'YEO' THEN '英式'
|
||
WHEN brand_code = 'OVV' THEN 'OVV'
|
||
WHEN brand_code = 'HLM' THEN '海澜优选'
|
||
WHEN brand_code = 'QIT' THEN '其他'
|
||
WHEN brand_code = 'SBZ' THEN '斯搏兹'
|
||
WHEN brand_code = 'AEX' THEN 'AEX'
|
||
WHEN brand_code = 'BES' THEN '海一家'
|
||
WHEN brand_code = 'HGS' THEN '蓝鲸'
|
||
WHEN brand_code = 'HED' THEN 'HEAD'
|
||
WHEN brand_code = 'VPG' THEN 'VPG'
|
||
WHEN brand_code = 'HLP' THEN 'HLA PLUS'
|
||
WHEN brand_code = 'JXH' THEN '京新海'
|
||
WHEN brand_code = 'LHB' THEN '企业购'
|
||
WHEN brand_code = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN brand_code = 'DIY' THEN '致加'
|
||
WHEN brand_code = 'HEA' THEN 'HEAD AURA'
|
||
ELSE brand_code
|
||
END AS "品牌名称",
|
||
SUM(sale_amount) AS "销售金额(元)",
|
||
SUM(return_amount) AS "退货金额(元)",
|
||
SUM(sale_amount) + SUM(return_amount) AS "净销售金额(元)"
|
||
FROM (SELECT
|
||
t1.perYear,
|
||
t1.brand_code,
|
||
t1.sale_amount,
|
||
t2.return_amount
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
MAX(brand_code) AS brand_code,
|
||
SUM(goods_amt) AS sale_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
store_code,
|
||
SUM(goods_amt) AS return_amount
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
) t2 ON t1.perYear = t2.perYear AND t1.store_code = t2.store_code
|
||
)
|
||
GROUP BY perYear, brand_code
|
||
ORDER BY perYear, (SUM(sale_amount) + SUM(return_amount)) DESC;
|
||
|
||
SQL28:
|
||
SELECT
|
||
SUBSTR(t1.mgclearTime, 1, 4) AS "年份",
|
||
t1.brandCode AS "店铺编码",
|
||
CASE WHEN t1.brandCode = 'HLA' THEN '海澜之家'
|
||
WHEN t1.brandCode = 'HJS' THEN '黑鲸'
|
||
WHEN t1.brandCode = 'NCL' THEN '男生女生'
|
||
WHEN t1.brandCode = 'YEO' THEN '英式'
|
||
WHEN t1.brandCode = 'OVV' THEN 'OVV'
|
||
WHEN t1.brandCode = 'HLM' THEN '海澜优选'
|
||
WHEN t1.brandCode = 'QIT' THEN '其他'
|
||
WHEN t1.brandCode = 'SBZ' THEN '斯搏兹'
|
||
WHEN t1.brandCode = 'AEX' THEN 'AEX'
|
||
WHEN t1.brandCode = 'BES' THEN '海一家'
|
||
WHEN t1.brandCode = 'HGS' THEN '蓝鲸'
|
||
WHEN t1.brandCode = 'HED' THEN 'HEAD'
|
||
WHEN t1.brandCode = 'VPG' THEN 'VPG'
|
||
WHEN t1.brandCode = 'HLP' THEN 'HLA PLUS'
|
||
WHEN t1.brandCode = 'JXH' THEN '京新海'
|
||
WHEN t1.brandCode = 'LHB' THEN '企业购'
|
||
WHEN t1.brandCode = 'HLX' THEN '海澜之家甄选好鞋'
|
||
WHEN t1.brandCode = 'DIY' THEN '致加'
|
||
WHEN t1.brandCode = 'HEA' THEN 'HEAD AURA'
|
||
ELSE t1.brandCode
|
||
END AS "品牌名称",
|
||
SUM(t1.goodsAmt) AS "销售金额(元)",
|
||
SUM(t2.returnGoodsAmt) AS "退货金额(元)",
|
||
SUM(t3.orderChangeAmt) AS "发货调整金额(元)",
|
||
SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) AS "净销售金额(元)"
|
||
FROM (
|
||
SELECT
|
||
store_code,
|
||
MAX(brand_code) AS brandCode,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclearTime,
|
||
SUM(real_goods_amt_mgclear_time) AS goodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_abroad_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
SUM(return_goods_qty) AS returnGoodsQty,
|
||
SUM(real_return_goods_amt) AS returnGoodsAmt
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t2 ON t1.store_code = t2.store_code AND t1.platform_order_no = t2.platform_order_no
|
||
LEFT JOIN (
|
||
SELECT store_code, platform_order_no, SUM(special_barcode_amt) AS orderChangeAmt
|
||
FROM (SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_change_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2024-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, platform_order_no
|
||
) t3 ON t1.store_code = t3.store_code AND t1.platform_order_no = t3.platform_order_no
|
||
GROUP BY SUBSTR(t1.mgclearTime, 1, 4), t1.brandCode
|
||
ORDER BY SUBSTR(t1.mgclearTime, 1, 4), SUM(t1.goodsAmt) + SUM(t2.returnGoodsAmt) + SUM(t3.orderChangeAmt) DESC;
|
||
|
||
SQL29:
|
||
SELECT
|
||
SUBSTR(completion_date , 1, 4) AS "年份",
|
||
SUM(sales_amount) AS "销售金额"
|
||
FROM dwd_trade_hkaudit_company_purchase_order_detail_mt
|
||
WHERE completion_date >= '20220101' AND completion_date <= '20250630'
|
||
GROUP BY SUBSTR(completion_date, 1, 4)
|
||
|
||
SQL30:
|
||
SELECT
|
||
SUBSTR(completion_date , 1, 4) AS "20240101-0630时间",
|
||
SUM(sales_amount) AS "销售金额"
|
||
FROM dwd_trade_hkaudit_company_purchase_order_detail_mt
|
||
WHERE completion_date >= '20240101' AND completion_date <= '20240630'
|
||
GROUP BY SUBSTR(completion_date, 1, 4)
|
||
ORDER BY SUBSTR(completion_date, 1, 4);
|
||
|
||
SQL31:
|
||
SELECT
|
||
SUBSTR(bill_date, 1, 4) AS "年份",
|
||
SUM(amount) AS "销售金额"
|
||
FROM dwd_settleother_hkaudit_scn_out_mt
|
||
WHERE bill_date >= '20220101' AND bill_date <= '20250630'
|
||
GROUP BY SUBSTR(bill_date, 1, 4)
|
||
ORDER BY SUBSTR(bill_date, 1, 4);
|
||
|
||
SQL32:
|
||
SELECT
|
||
SUBSTR(bill_date, 1, 4) AS "20240101-0630时间",
|
||
SUM(amount) AS "销售金额"
|
||
FROM dwd_settleother_hkaudit_scn_out_mt
|
||
WHERE bill_date >= '20240101' AND bill_date <= '20240630'
|
||
GROUP BY SUBSTR(bill_date, 1, 4)
|
||
ORDER BY SUBSTR(bill_date, 1, 4);
|
||
|
||
SQL33:
|
||
SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS "年份",
|
||
SUBSTR(order_time_t, 6, 2) AS "月份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name_t) AS "店铺名称",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量",
|
||
ROUND((SUM(real_goods_amt_t) + SUM(order_freight_amt_t)) / COUNT(DISTINCT platform_order_no), 2) AS "订单均价(元)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), SUBSTR(order_time_t, 6, 2), store_code
|
||
ORDER BY SUBSTR(order_time_t, 1, 4), store_code, SUBSTR(order_time_t, 6, 2);
|
||
|
||
SQL34:
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS "年份",
|
||
SUBSTR(order_time, 6, 2) AS "月份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name) AS "店铺名称",
|
||
SUM(goods_amt) AS "销售金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), SUBSTR(order_time, 6, 2), store_code
|
||
ORDER BY SUBSTR(order_time, 1, 4), store_code, SUBSTR(order_time, 6, 2);
|
||
|
||
SQL35:
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS "年份",
|
||
SUBSTR(mgclear_time_t, 6, 2) AS "月份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name_t) AS "店铺名称",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量",
|
||
ROUND((SUM(real_goods_amt_t) + SUM(order_freight_amt_t)) / COUNT(DISTINCT platform_order_no), 2) AS "订单均价(元)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), SUBSTR(mgclear_time_t, 6, 2), store_code
|
||
ORDER BY SUBSTR(mgclear_time_t, 1, 4), store_code, SUBSTR(mgclear_time_t, 6, 2);
|
||
|
||
SQL36:
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS "年份",
|
||
SUBSTR(mgclear_time, 6, 2) AS "月份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name) AS "店铺名称",
|
||
SUM(goods_amt) AS "销售金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), SUBSTR(mgclear_time, 6, 2), store_code
|
||
ORDER BY SUBSTR(mgclear_time, 1, 4), store_code, SUBSTR(mgclear_time, 6, 2);
|
||
|
||
SQL37:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.goods_barcode AS "商品条码",
|
||
MAX(t2.goods_name) AS "商品名称",
|
||
SUM(t1.goods_qty) AS "商品数量",
|
||
SUM(t1.goods_amt) AS "商品销售金额(元)"
|
||
FROM (SELECT
|
||
SUBSTR(min_order_time, 1, 4) AS perYear,
|
||
goods_barcode,
|
||
goods_qty,
|
||
real_goods_amt AS goods_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
UNION ALL
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS perYear,
|
||
goods_barcode,
|
||
goods_qty,
|
||
goods_amt
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
) t1 LEFT JOIN (
|
||
SELECT barcode, MAX(goods_desc) AS goods_name
|
||
FROM (SELECT barcode, goods_desc FROM dim_hkaudit_goods_mt WHERE country = 'CN'
|
||
UNION ALL
|
||
SELECT barcode, goods_desc FROM dim_hkaudit_goods_other_mt
|
||
) GROUP BY barcode
|
||
) t2 ON t1.goods_barcode = t2.barcode
|
||
GROUP BY t1.perYear, t1.goods_barcode
|
||
ORDER BY t1.perYear, SUM(t1.goods_amt) DESC;
|
||
|
||
SQL38:
|
||
SELECT
|
||
t1.perYear AS "年份",
|
||
t1.goods_barcode AS "商品条码",
|
||
MAX(t2.goods_name) AS "商品名称",
|
||
SUM(t1.goods_qty) AS "商品数量",
|
||
SUM(t1.goods_amt) AS "商品销售金额(元)"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
goods_barcode,
|
||
goods_qty,
|
||
real_goods_amt AS goods_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
UNION ALL
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS perYear,
|
||
goods_barcode,
|
||
goods_qty,
|
||
goods_amt
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
) t1 LEFT JOIN (
|
||
SELECT barcode, MAX(goods_desc) AS goods_name
|
||
FROM (SELECT barcode, goods_desc FROM dim_hkaudit_goods_mt WHERE country = 'CN'
|
||
UNION ALL
|
||
SELECT barcode, goods_desc FROM dim_hkaudit_goods_other_mt
|
||
) GROUP BY barcode
|
||
) t2 ON t1.goods_barcode = t2.barcode
|
||
GROUP BY t1.perYear, t1.goods_barcode
|
||
ORDER BY t1.perYear, SUM(t1.goods_amt) DESC;
|
||
|
||
SQL39:
|
||
SELECT
|
||
a.perYear AS "年份",
|
||
a.province_t AS "省份",
|
||
a.goodsAmt AS "销售金额(元)",
|
||
a.orderFreightAmt AS "运费金额(元)",
|
||
a.goodsAmt + a.orderFreightAmt AS "销售金额(元)(包含运费)",
|
||
a.order_amt AS "订单数量",
|
||
b.all_order_count AS "订单总数量",
|
||
ROUND(a.order_amt / b.all_order_count, 4) AS "订单占比"
|
||
FROM (SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS perYear,
|
||
province_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(province) AS province_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND province <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND province <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), province_t
|
||
) a LEFT JOIN (
|
||
SELECT
|
||
perYear,
|
||
SUM(order_amt) AS all_order_count
|
||
FROM (SELECT SUBSTR(min_order_time, 1, 4) AS perYear, province, COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND province <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND province <> ''
|
||
)
|
||
GROUP BY SUBSTR(min_order_time, 1, 4), province
|
||
) GROUP BY perYear
|
||
) b ON a.perYear = b.perYear
|
||
ORDER BY a.perYear, a.goodsAmt + a.orderFreightAmt DESC;
|
||
|
||
SQL40:
|
||
SELECT
|
||
a.perYear AS "年份",
|
||
a.province_t AS "省份",
|
||
a.goodsAmt AS "销售金额(元)",
|
||
a.orderFreightAmt AS "运费金额(元)",
|
||
a.goodsAmt + a.orderFreightAmt AS "销售金额(元)(包含运费)",
|
||
a.order_amt AS "订单数量",
|
||
b.all_order_count AS "订单总数量",
|
||
ROUND(a.order_amt / b.all_order_count, 4) AS "订单占比"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
province_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(province) AS province_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND province <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND province <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), province_t
|
||
) a LEFT JOIN (
|
||
SELECT
|
||
perYear,
|
||
SUM(order_amt) AS all_order_count
|
||
FROM (SELECT SUBSTR(mgclear_time, 1, 4) AS perYear, province, COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND province <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND province <> ''
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), province
|
||
) GROUP BY perYear
|
||
) b ON a.perYear = b.perYear
|
||
ORDER BY a.perYear, a.goodsAmt + a.orderFreightAmt DESC;
|
||
|
||
SQL41:
|
||
SELECT
|
||
a.perYear AS "年份",
|
||
a.city_grade_t AS "城市等级",
|
||
a.goodsAmt AS "销售金额(元)",
|
||
a.orderFreightAmt AS "运费金额(元)",
|
||
a.goodsAmt + a.orderFreightAmt AS "销售金额(元)(包含运费)",
|
||
a.order_amt AS "订单数量",
|
||
b.all_order_count AS "订单总数量",
|
||
ROUND(a.order_amt / b.all_order_count, 4) AS "订单占比"
|
||
FROM (SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS perYear,
|
||
city_grade_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(t2.city_grade) AS city_grade_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
) t1
|
||
LEFT JOIN custom_online_city_grade_local t2 ON t1.city = t2.city
|
||
WHERE t2.city_grade <> ''
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), city_grade_t
|
||
) a LEFT JOIN (
|
||
SELECT
|
||
perYear,
|
||
SUM(order_amt) AS all_order_count
|
||
FROM (SELECT SUBSTR(min_order_time, 1, 4) AS perYear, t2.city_grade, COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
) t1
|
||
LEFT JOIN custom_online_city_grade_local t2 ON t1.city = t2.city
|
||
WHERE t2.city_grade <> ''
|
||
GROUP BY SUBSTR(min_order_time, 1, 4), t2.city_grade
|
||
) GROUP BY perYear
|
||
) b ON a.perYear = b.perYear
|
||
ORDER BY a.perYear, a.goodsAmt + a.orderFreightAmt DESC;
|
||
|
||
SQL42:
|
||
SELECT
|
||
a.perYear AS "年份",
|
||
a.city_grade_t AS "城市等级",
|
||
a.goodsAmt AS "销售金额(元)",
|
||
a.orderFreightAmt AS "运费金额(元)",
|
||
a.goodsAmt + a.orderFreightAmt AS "销售金额(元)(包含运费)",
|
||
a.order_amt AS "订单数量",
|
||
b.all_order_count AS "订单总数量",
|
||
ROUND(a.order_amt / b.all_order_count, 4) AS "订单占比"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
city_grade_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(t2.city_grade) AS city_grade_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
) t1
|
||
LEFT JOIN custom_online_city_grade_local t2 ON t1.city = t2.city
|
||
WHERE t2.city_grade <> ''
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), city_grade_t
|
||
) a LEFT JOIN (
|
||
SELECT
|
||
perYear,
|
||
SUM(order_amt) AS all_order_count
|
||
FROM (SELECT SUBSTR(mgclear_time, 1, 4) AS perYear, t2.city_grade, COUNT(DISTINCT platform_order_no) AS order_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
) t1
|
||
LEFT JOIN custom_online_city_grade_local t2 ON t1.city = t2.city
|
||
WHERE t2.city_grade <> ''
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), t2.city_grade
|
||
) GROUP BY perYear
|
||
) b ON a.perYear = b.perYear
|
||
ORDER BY a.perYear, a.goodsAmt + a.orderFreightAmt DESC;
|
||
|
||
SQL43:
|
||
SELECT
|
||
perYear AS "年份",
|
||
consignee_add_t AS "收货地址",
|
||
goodsAmt AS "销售金额(元)",
|
||
orderFreightAmt AS "运费金额(元)",
|
||
saleMoney AS "销售金额(元)(包含运费)",
|
||
orderCount AS "订单数量"
|
||
FROM (SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS perYear,
|
||
consignee_add_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS saleMoney,
|
||
COUNT(DISTINCT platform_order_no) AS orderCount,
|
||
RANK() OVER (
|
||
PARTITION BY SUBSTR(order_time_t, 1, 4)
|
||
ORDER BY SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC
|
||
) AS rn
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(consignee_add) AS consignee_add_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND consignee_add <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND consignee_add <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), consignee_add_t
|
||
) WHERE rn <= 2000
|
||
ORDER BY perYear, saleMoney DESC;
|
||
|
||
SQL44:
|
||
SELECT
|
||
perYear AS "年份",
|
||
consignee_add_t AS "收货地址",
|
||
goodsAmt AS "销售金额(元)",
|
||
orderFreightAmt AS "运费金额(元)",
|
||
saleMoney AS "销售金额(元)(包含运费)",
|
||
orderCount AS "订单数量"
|
||
FROM (SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS perYear,
|
||
consignee_add_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS saleMoney,
|
||
COUNT(DISTINCT platform_order_no) AS orderCount,
|
||
RANK() OVER (
|
||
PARTITION BY SUBSTR(order_time_t, 1, 4)
|
||
ORDER BY SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC
|
||
) AS rn
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
CONCAT(MAX(province), MAX(consignee_add)) AS consignee_add_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND consignee_add <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND consignee_add <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), consignee_add_t
|
||
) WHERE rn <= 2000
|
||
ORDER BY perYear, saleMoney DESC;
|
||
|
||
SQL45:
|
||
SELECT
|
||
perYear AS "年份",
|
||
consignee_add_t AS "收货地址",
|
||
goodsAmt AS "销售金额(元)",
|
||
orderFreightAmt AS "运费金额(元)",
|
||
saleMoney AS "销售金额(元)(包含运费)",
|
||
orderCount AS "订单数量"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
consignee_add_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS saleMoney,
|
||
COUNT(DISTINCT platform_order_no) AS orderCount,
|
||
RANK() OVER (
|
||
PARTITION BY SUBSTR(mgclear_time_t, 1, 4)
|
||
ORDER BY SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC
|
||
) AS rn
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(consignee_add) AS consignee_add_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND consignee_add <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND consignee_add <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), consignee_add_t
|
||
) WHERE rn <= 2000
|
||
ORDER BY perYear, saleMoney DESC;
|
||
|
||
SQL46:
|
||
SELECT
|
||
perYear AS "年份",
|
||
consignee_add_t AS "收货地址",
|
||
goodsAmt AS "销售金额(元)",
|
||
orderFreightAmt AS "运费金额(元)",
|
||
saleMoney AS "销售金额(元)(包含运费)",
|
||
orderCount AS "订单数量"
|
||
FROM (SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS perYear,
|
||
consignee_add_t,
|
||
SUM(real_goods_amt_t) AS goodsAmt,
|
||
SUM(order_freight_amt_t) AS orderFreightAmt,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS saleMoney,
|
||
COUNT(DISTINCT platform_order_no) AS orderCount,
|
||
RANK() OVER (
|
||
PARTITION BY SUBSTR(mgclear_time_t, 1, 4)
|
||
ORDER BY SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC
|
||
) AS rn
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
CONCAT(MAX(province), MAX(consignee_add)) AS consignee_add_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND consignee_add <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND consignee_add <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), consignee_add_t
|
||
) WHERE rn <= 2000
|
||
ORDER BY perYear, saleMoney DESC;
|
||
|
||
SQL47:
|
||
SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS "年份",
|
||
SUBSTR(order_time_t, 6, 5) AS "日期",
|
||
SUM(real_goods_amt) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), SUBSTR(order_time_t, 6, 5)
|
||
ORDER BY SUBSTR(order_time_t, 1, 4), SUM(real_goods_amt) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL48:
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS "年份",
|
||
SUBSTR(order_time, 6, 5) AS "日期",
|
||
SUM(goods_amt) AS "销售金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), SUBSTR(order_time, 6, 5)
|
||
ORDER BY SUBSTR(order_time, 1, 4), SUM(goods_amt) DESC;
|
||
|
||
SQL49:
|
||
SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS "年份",
|
||
time_area AS "时间区间",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
CASE WHEN LENGTH(order_time_t) > 10 THEN
|
||
CASE
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 0 THEN '0-1点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 1 THEN '1-2点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 2 THEN '2-3点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 3 THEN '3-4点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 4 THEN '4-5点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 5 THEN '5-6点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 6 THEN '6-7点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 7 THEN '7-8点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 8 THEN '8-9点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 9 THEN '9-10点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 10 THEN '10-11点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 11 THEN '11-12点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 12 THEN '12-13点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 13 THEN '13-14点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 14 THEN '14-15点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 15 THEN '15-16点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 16 THEN '16-17点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 17 THEN '17-18点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 18 THEN '18-19点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 19 THEN '19-20点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 20 THEN '20-21点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 21 THEN '21-22点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 22 THEN '22-23点'
|
||
WHEN toInt32(SUBSTR(order_time_t, 12, 2)) = 23 THEN '23-24点'
|
||
END
|
||
ELSE '其他' END AS time_area
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
WHERE time_area <> '其他'
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), time_area
|
||
ORDER BY SUBSTR(order_time_t, 1, 4), SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL50:
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS "年份",
|
||
time_area AS "时间区间",
|
||
SUM(goods_amt) AS "销售金额(元)"
|
||
FROM (SELECT
|
||
order_time,
|
||
CASE
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 0 THEN '0-1点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 1 THEN '1-2点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 2 THEN '2-3点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 3 THEN '3-4点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 4 THEN '4-5点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 5 THEN '5-6点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 6 THEN '6-7点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 7 THEN '7-8点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 8 THEN '8-9点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 9 THEN '9-10点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 10 THEN '10-11点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 11 THEN '11-12点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 12 THEN '12-13点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 13 THEN '13-14点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 14 THEN '14-15点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 15 THEN '15-16点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 16 THEN '16-17点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 17 THEN '17-18点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 18 THEN '18-19点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 19 THEN '19-20点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 20 THEN '20-21点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 21 THEN '21-22点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 22 THEN '22-23点'
|
||
WHEN toInt32(SUBSTR(order_time, 12, 2)) = 23 THEN '23-24点'
|
||
END AS time_area,
|
||
goods_amt
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND LENGTH(order_time) > 10
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND LENGTH(order_time) > 10
|
||
)
|
||
) GROUP BY SUBSTR(order_time, 1, 4), time_area
|
||
ORDER BY SUBSTR(order_time, 1, 4), SUM(goods_amt) DESC;
|
||
|
||
SQL51:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t_t AS "店铺名称",
|
||
t3.sale_money AS "2022年618销售金额(元)(包含运费)",
|
||
t3.order_count AS "2022年618订单数量",
|
||
t2.sale_money AS "2022年双11销售金额(元)(包含运费)",
|
||
t2.order_count AS "2022年双11订单数量",
|
||
t1.all_sale_money AS "2022年总销售金额(元)(包含运费)",
|
||
t1.all_order_count AS "2022年总订单数量",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t3.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "2022年618销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t3.order_count / t1.all_order_count, 4) END AS "2022年618订单数量占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "2022年双11销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t2.order_count / t1.all_order_count, 4) END AS "2022年双11订单数量占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name_t) AS store_name_t_t,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS all_sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS all_order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2022-12-31'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-10-31' AND SUBSTR(min_order_time, 1, 10) <= '2022-11-11'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-05-31' AND SUBSTR(min_order_time, 1, 10) <= '2022-06-20'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t3 ON t1.store_code = t3.store_code
|
||
ORDER BY t1.all_sale_money DESC;
|
||
|
||
SQL52:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t_t AS "店铺名称",
|
||
t3.sale_money AS "2023年618销售金额(元)(包含运费)",
|
||
t3.order_count AS "2023年618订单数量",
|
||
t2.sale_money AS "2023年双11销售金额(元)(包含运费)",
|
||
t2.order_count AS "2023年双11订单数量",
|
||
t1.all_sale_money AS "2023年总销售金额(元)(包含运费)",
|
||
t1.all_order_count AS "2023年总订单数量",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t3.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "2023年618销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t3.order_count / t1.all_order_count, 4) END AS "2023年618订单数量占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "2023年双11销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t2.order_count / t1.all_order_count, 4) END AS "2023年双11订单数量占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name_t) AS store_name_t_t,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS all_sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS all_order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2023-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2023-12-31'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2023-10-20' AND SUBSTR(min_order_time, 1, 10) <= '2023-11-11'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2023-05-31' AND SUBSTR(min_order_time, 1, 10) <= '2023-06-20'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t3 ON t1.store_code = t3.store_code
|
||
ORDER BY t1.all_sale_money DESC;
|
||
|
||
SQL53:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t_t AS "店铺名称",
|
||
t3.sale_money AS "2024年618销售金额(元)(包含运费)",
|
||
t3.order_count AS "2024年618订单数量",
|
||
t2.sale_money AS "2024年双11销售金额(元)(包含运费)",
|
||
t2.order_count AS "2024年双11订单数量",
|
||
t1.all_sale_money AS "2024年总销售金额(元)(包含运费)",
|
||
t1.all_order_count AS "2024年总订单数量",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t3.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "2024年618销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t3.order_count / t1.all_order_count, 4) END AS "2024年618订单数量占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "2024年双11销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t2.order_count / t1.all_order_count, 4) END AS "2024年双11订单数量占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name_t) AS store_name_t_t,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS all_sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS all_order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2024-12-31' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2024-12-31' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-10-17' AND SUBSTR(min_order_time, 1, 10) <= '2024-11-11'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-20' AND SUBSTR(min_order_time, 1, 10) <= '2024-06-20'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t3 ON t1.store_code = t3.store_code
|
||
ORDER BY t1.all_sale_money DESC;
|
||
|
||
SQL54:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t_t AS "店铺名称",
|
||
t2.sale_money AS "2025年618销售金额(元)(包含运费)",
|
||
t2.order_count AS "2025年618订单数量",
|
||
t1.all_sale_money AS "20250630总销售金额(元)(包含运费)",
|
||
t1.all_order_count AS "20250630总订单数量",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_money, 5) / toDecimal64(t1.all_sale_money, 5), 4) END AS "到20250630·618销售金额占比",
|
||
CASE WHEN t1.all_sale_money = 0 THEN 0 ELSE ROUND(t2.order_count / t1.all_order_count, 4) END AS "到20250630·618订单数量占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name_t) AS store_name_t_t,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS all_sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS all_order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2025-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t1 LEFT JOIN (
|
||
SELECT
|
||
store_code,
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS sale_money,
|
||
COUNT(DISTINCT platform_order_no) AS order_count
|
||
FROM (SELECT
|
||
store_code,
|
||
platform_order_no,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t
|
||
FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2025-05-16' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-20'
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
) GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code
|
||
ORDER BY t1.all_sale_money DESC;
|
||
|
||
SQL55:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t AS "店铺名称",
|
||
t3.sale_amt AS "2022年618销售金额(元)",
|
||
t2.sale_amt AS "2022年双11销售金额(元)",
|
||
t1.all_sale_amt AS "2022年总销售金额(元)",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t3.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "2022年618销售金额占比",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "2022年双11销售金额占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
SUM(goods_amt) AS all_sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2022-12-31'
|
||
GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-10-31' AND SUBSTR(order_time, 1, 10) <= '2022-11-11'
|
||
GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2022-05-31' AND SUBSTR(order_time, 1, 10) <= '2022-06-20'
|
||
GROUP BY store_code
|
||
) t3 ON t1.store_code = t3.store_code
|
||
ORDER BY t1.all_sale_amt DESC;
|
||
|
||
SQL56:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t AS "店铺名称",
|
||
t3.sale_amt AS "2023年618销售金额(元)",
|
||
t2.sale_amt AS "2023年双11销售金额(元)",
|
||
t1.all_sale_amt AS "2023年总销售金额(元)",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t3.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "2023年618销售金额占比",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "2023年双11销售金额占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
SUM(goods_amt) AS all_sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2023-01-01' AND SUBSTR(order_time, 1, 10) <= '2023-12-31'
|
||
GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2023-10-20' AND SUBSTR(order_time, 1, 10) <= '2023-11-11'
|
||
GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2023-05-31' AND SUBSTR(order_time, 1, 10) <= '2023-06-20'
|
||
GROUP BY store_code
|
||
) t3 ON t1.store_code = t3.store_code
|
||
ORDER BY t1.all_sale_amt DESC;
|
||
|
||
SQL57:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t AS "店铺名称",
|
||
t3.sale_amt AS "2024年618销售金额(元)",
|
||
t2.sale_amt AS "2024年双11销售金额(元)",
|
||
t1.all_sale_amt AS "2024年总销售金额(元)",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t3.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "2024年618销售金额占比",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "2024年双11销售金额占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
SUM(goods_amt) AS all_sale_amt
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-01-01' AND SUBSTR(order_time, 1, 10) <= '2024-12-31' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2024-12-31' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-10-17' AND SUBSTR(order_time, 1, 10) <= '2024-11-11'
|
||
GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-20' AND SUBSTR(order_time, 1, 10) <= '2024-06-20'
|
||
GROUP BY store_code
|
||
) t3 ON t1.store_code = t3.store_code
|
||
ORDER BY t1.all_sale_amt DESC;
|
||
|
||
SQL58:
|
||
SELECT
|
||
t1.store_code AS "店铺编码",
|
||
t1.store_name_t AS "店铺名称",
|
||
t2.sale_amt AS "2025年618销售金额(元)",
|
||
t1.all_sale_amt AS "20250630总销售金额(元)",
|
||
CASE WHEN t1.all_sale_amt = 0 THEN 0 ELSE ROUND(toDecimal64(t2.sale_amt, 5) / toDecimal64(t1.all_sale_amt, 5), 4) END AS "到20250630·618销售金额占比"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
SUM(goods_amt) AS all_sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2025-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30'
|
||
GROUP BY store_code
|
||
) t1 LEFT JOIN (SELECT
|
||
store_code,
|
||
SUM(goods_amt) AS sale_amt
|
||
FROM custom_online_sale_bill_local
|
||
WHERE goods_amt >= 0 AND SUBSTR(order_time, 1, 10) >= '2025-05-16' AND SUBSTR(order_time, 1, 10) <= '2025-06-20'
|
||
GROUP BY store_code
|
||
) t2 ON t1.store_code = t2.store_code
|
||
ORDER BY t1.all_sale_amt DESC;
|
||
|
||
SQL59:
|
||
SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS "年份",
|
||
time_diff AS "发货间隔",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MIN(deliver_time) AS deliver_time_t,
|
||
CASE WHEN deliver_time_t <> '' AND order_time_t <> '' THEN
|
||
CASE
|
||
WHEN dateDiff('minute', toDateTime(deliver_time_t), toDateTime(order_time_t)) <= 240 THEN '0-4小时'
|
||
WHEN dateDiff('minute', toDateTime(deliver_time_t), toDateTime(order_time_t)) > 240
|
||
AND dateDiff('minute', toDateTime(deliver_time_t), toDateTime(order_time_t)) <= 1440 THEN '4-24小时'
|
||
WHEN dateDiff('minute', toDateTime(deliver_time_t), toDateTime(order_time_t)) > 1440
|
||
AND dateDiff('minute', toDateTime(deliver_time_t), toDateTime(order_time_t)) <= 2880 THEN '24-48小时'
|
||
WHEN dateDiff('minute', toDateTime(deliver_time_t), toDateTime(order_time_t)) > 2880 THEN '大于48小时'
|
||
END
|
||
ELSE '其他'
|
||
END AS time_diff
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
WHERE time_diff <> '其他'
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), time_diff
|
||
ORDER BY SUBSTR(order_time_t, 1, 4), SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL60:
|
||
SELECT
|
||
SUBSTR(order_time_t, 1, 4) AS "年份",
|
||
carrierName AS "承运商",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_order_time) AS order_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(carrier) AS carrier_t,
|
||
CASE
|
||
WHEN carrier_t IN ('shunfeng') OR carrier_t LIKE 'sf%' OR carrier_t LIKE 'SF%' OR carrier_t LIKE '顺丰%' THEN '顺丰'
|
||
WHEN carrier_t IN ('postb', 'eyb') OR carrier_t LIKE 'ems%' OR carrier_t LIKE 'EMS%' THEN '邮政'
|
||
WHEN carrier_t LIKE 'yunda%' OR carrier_t LIKE 'YUNDA%' THEN '韵达'
|
||
WHEN carrier_t IN ('ZT') OR carrier_t LIKE 'zto%' OR carrier_t LIKE 'ZTO%' OR carrier_t LIKE '中通%' THEN '中通'
|
||
WHEN carrier_t LIKE 'jd%' OR carrier_t LIKE 'JD%' OR carrier_t LIKE '京东%' THEN '京东'
|
||
WHEN carrier_t IN ('ST#DW', 'ST') OR carrier_t LIKE 'sto%' OR carrier_t LIKE 'STO%' OR carrier_t LIKE '申通%' THEN '申通'
|
||
WHEN carrier_t LIKE 'jt%' OR carrier_t LIKE 'JT%' THEN '极兔'
|
||
WHEN carrier_t IN ('YT') OR carrier_t LIKE 'yto%' OR carrier_t LIKE 'YTO%' OR carrier_t LIKE '圆通%' THEN '圆通'
|
||
WHEN carrier_t IN ('rider') THEN '骑士'
|
||
WHEN carrier_t IN ('dbl') THEN '德邦'
|
||
WHEN carrier_t IN ('htky') THEN '汇通'
|
||
WHEN carrier_t IN ('QSKD') THEN '千顺'
|
||
WHEN carrier_t IN ('fengwang') THEN '丰网'
|
||
WHEN carrier_t IN ('best') THEN '百世'
|
||
WHEN carrier_t IN ('ttkdex') THEN '天天'
|
||
ELSE carrier_t
|
||
END AS carrierName
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND carrier <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND carrier <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(order_time_t, 1, 4), carrierName
|
||
ORDER BY SUBSTR(order_time_t, 1, 4), SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL61:
|
||
SELECT
|
||
SUBSTR(min_order_time, 1, 4) AS "年份",
|
||
SUBSTR(min_order_time, 6, 2) AS "月份",
|
||
COUNT(DISTINCT main_logistic_bill) AS "物流单数量"
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND main_logistic_bill <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE SUBSTR(min_order_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND main_logistic_bill <> ''
|
||
)
|
||
GROUP BY SUBSTR(min_order_time, 1, 4), SUBSTR(min_order_time, 6, 2)
|
||
ORDER BY SUBSTR(min_order_time, 1, 4), SUBSTR(min_order_time, 6, 2);
|
||
|
||
SQL62:
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS "年份",
|
||
carrierName AS "承运商",
|
||
SUM(real_goods_amt_t) AS "销售金额(元)",
|
||
SUM(order_freight_amt_t) AS "运费金额(元)",
|
||
SUM(real_goods_amt_t) + SUM(order_freight_amt_t) AS "销售金额(元)(包含运费)",
|
||
COUNT(DISTINCT platform_order_no) AS "订单数量"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(order_freight_amt) AS order_freight_amt_t,
|
||
SUM(goods_qty) AS goods_qty_t,
|
||
SUM(real_goods_amt) AS real_goods_amt_t,
|
||
MAX(carrier) AS carrier_t,
|
||
CASE
|
||
WHEN carrier_t IN ('shunfeng') OR carrier_t LIKE 'sf%' OR carrier_t LIKE 'SF%' OR carrier_t LIKE '顺丰%' THEN '顺丰'
|
||
WHEN carrier_t IN ('postb', 'eyb') OR carrier_t LIKE 'ems%' OR carrier_t LIKE 'EMS%' THEN '邮政'
|
||
WHEN carrier_t LIKE 'yunda%' OR carrier_t LIKE 'YUNDA%' THEN '韵达'
|
||
WHEN carrier_t IN ('ZT') OR carrier_t LIKE 'zto%' OR carrier_t LIKE 'ZTO%' OR carrier_t LIKE '中通%' THEN '中通'
|
||
WHEN carrier_t LIKE 'jd%' OR carrier_t LIKE 'JD%' OR carrier_t LIKE '京东%' THEN '京东'
|
||
WHEN carrier_t IN ('ST#DW', 'ST') OR carrier_t LIKE 'sto%' OR carrier_t LIKE 'STO%' OR carrier_t LIKE '申通%' THEN '申通'
|
||
WHEN carrier_t LIKE 'jt%' OR carrier_t LIKE 'JT%' THEN '极兔'
|
||
WHEN carrier_t IN ('YT') OR carrier_t LIKE 'yto%' OR carrier_t LIKE 'YTO%' OR carrier_t LIKE '圆通%' THEN '圆通'
|
||
WHEN carrier_t IN ('rider') THEN '骑士'
|
||
WHEN carrier_t IN ('dbl') THEN '德邦'
|
||
WHEN carrier_t IN ('htky') THEN '汇通'
|
||
WHEN carrier_t IN ('QSKD') THEN '千顺'
|
||
WHEN carrier_t IN ('fengwang') THEN '丰网'
|
||
WHEN carrier_t IN ('best') THEN '百世'
|
||
WHEN carrier_t IN ('ttkdex') THEN '天天'
|
||
ELSE carrier_t
|
||
END AS carrierName
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND carrier <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND carrier <> ''
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), carrierName
|
||
ORDER BY SUBSTR(mgclear_time_t, 1, 4), SUM(real_goods_amt_t) + SUM(order_freight_amt_t) DESC;
|
||
|
||
SQL63:
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS "年份",
|
||
SUBSTR(mgclear_time, 6, 2) AS "月份",
|
||
COUNT(DISTINCT main_logistic_bill) AS "物流单数量"
|
||
FROM (SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ' AND main_logistic_bill <> ''
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_order_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ' AND main_logistic_bill <> ''
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), SUBSTR(mgclear_time, 6, 2)
|
||
ORDER BY SUBSTR(mgclear_time, 1, 4), SUBSTR(mgclear_time, 6, 2);
|
||
|
||
SQL64:
|
||
SELECT
|
||
SUBSTR(min_create_time_t, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name_t) AS "店铺名称",
|
||
SUM(real_return_goods_amt_t) AS "退款金额(元)",
|
||
SUM(return_freight_amt_t) AS "退款运费金额(元)",
|
||
SUM(real_return_goods_amt_t) + SUM(return_freight_amt_t) AS "退款金额(元)(包含退款运费)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_create_time) AS min_create_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE SUBSTR(min_create_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_create_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE SUBSTR(min_create_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_create_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(min_create_time_t, 1, 4), store_code
|
||
ORDER BY SUBSTR(min_create_time_t, 1, 4), SUM(real_return_goods_amt_t) + SUM(return_freight_amt_t);
|
||
|
||
SQL65:
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name) AS "店铺名称",
|
||
SUM(goods_amt) AS "退款金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), store_code
|
||
ORDER BY SUBSTR(order_time, 1, 4), SUM(goods_amt);
|
||
|
||
SQL66:
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name_t) AS "店铺名称",
|
||
SUM(real_return_goods_amt_t) AS "退款金额(元)",
|
||
SUM(return_freight_amt_t) AS "退款运费金额(元)",
|
||
SUM(real_return_goods_amt_t) + SUM(return_freight_amt_t) AS "退款金额(元)(包含退款运费)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), store_code
|
||
ORDER BY SUBSTR(mgclear_time_t, 1, 4), SUM(real_return_goods_amt_t) + SUM(return_freight_amt_t);
|
||
|
||
SQL67:
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS "年份",
|
||
store_code AS "店铺编码",
|
||
MAX(store_name) AS "店铺名称",
|
||
SUM(goods_amt) AS "退款金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), store_code
|
||
ORDER BY SUBSTR(mgclear_time, 1, 4), SUM(goods_amt);
|
||
|
||
SQL68:
|
||
SELECT
|
||
SUBSTR(min_create_time_t, 1, 4) AS "年份",
|
||
SUBSTR(min_create_time_t, 6, 2) AS "月份",
|
||
SUM(real_return_goods_amt_t) AS "退款金额(元)",
|
||
SUM(return_freight_amt_t) AS "退款运费金额(元)",
|
||
SUM(real_return_goods_amt_t) + SUM(return_freight_amt_t) AS "退款金额(元)(包含退款运费)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(min_create_time) AS min_create_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE SUBSTR(min_create_time, 1, 10) >= '2022-01-01' AND SUBSTR(min_create_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE SUBSTR(min_create_time, 1, 10) >= '2024-05-01' AND SUBSTR(min_create_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(min_create_time_t, 1, 4), SUBSTR(min_create_time_t, 6, 2)
|
||
ORDER BY SUBSTR(min_create_time_t, 1, 4), SUBSTR(min_create_time_t, 6, 2);
|
||
|
||
SQL69:
|
||
SELECT
|
||
SUBSTR(order_time, 1, 4) AS "年份",
|
||
SUBSTR(order_time, 6, 2) AS "月份",
|
||
SUM(goods_amt) AS "退款金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2022-01-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND SUBSTR(order_time, 1, 10) >= '2024-05-01' AND SUBSTR(order_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(order_time, 1, 4), SUBSTR(order_time, 6, 2)
|
||
ORDER BY SUBSTR(order_time, 1, 4), SUBSTR(order_time, 6, 2);
|
||
|
||
SQL70:
|
||
SELECT
|
||
SUBSTR(mgclear_time_t, 1, 4) AS "年份",
|
||
SUBSTR(mgclear_time_t, 6, 2) AS "月份",
|
||
SUM(real_return_goods_amt_t) AS "退款金额(元)",
|
||
SUM(return_freight_amt_t) AS "退款运费金额(元)",
|
||
SUM(real_return_goods_amt_t) + SUM(return_freight_amt_t) AS "退款金额(元)(包含退款运费)"
|
||
FROM (SELECT
|
||
store_code,
|
||
MAX(store_name) AS store_name_t,
|
||
system_order_no,
|
||
platform_order_no,
|
||
MIN(mgclear_time) AS mgclear_time_t,
|
||
MAX(return_freight_amt) AS return_freight_amt_t,
|
||
SUM(return_goods_qty) AS return_goods_qty_t,
|
||
SUM(real_return_goods_amt) AS real_return_goods_amt_t
|
||
FROM (SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_return_local
|
||
WHERE mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY store_code, system_order_no, platform_order_no
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time_t, 1, 4), SUBSTR(mgclear_time_t, 6, 2)
|
||
ORDER BY SUBSTR(mgclear_time_t, 1, 4), SUBSTR(mgclear_time_t, 6, 2);
|
||
|
||
SQL71:
|
||
SELECT
|
||
SUBSTR(mgclear_time, 1, 4) AS "年份",
|
||
SUBSTR(mgclear_time, 6, 2) AS "月份",
|
||
SUM(goods_amt) AS "退款金额(元)"
|
||
FROM (SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2022-01-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code <> 'SBZ'
|
||
UNION ALL
|
||
SELECT * FROM custom_online_sale_bill_local
|
||
WHERE goods_amt < 0 AND mgclear_time <> '' AND SUBSTR(mgclear_time, 1, 10) >= '2024-05-01' AND SUBSTR(mgclear_time, 1, 10) <= '2025-06-30' AND brand_code = 'SBZ'
|
||
)
|
||
GROUP BY SUBSTR(mgclear_time, 1, 4), SUBSTR(mgclear_time, 6, 2)
|
||
ORDER BY SUBSTR(mgclear_time, 1, 4), SUBSTR(mgclear_time, 6, 2);
|
||
|
||
SQL72:
|
||
SELECT
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 4) < '2023' THEN member_id END) AS "2022年底会员数量",
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 4) < '2024' THEN member_id END) AS "2023年底会员数量",
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 4) < '2025' THEN member_id END) AS "2024年底会员数量",
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 10) <= '2025-06-30' THEN member_id END) AS "20250630会员数量"
|
||
FROM (
|
||
SELECT brand, member_id, MIN(member_register_time) AS member_register_time_t
|
||
FROM dwd_basic_all_vip_info_dd
|
||
WHERE member_register_time <= '2025-06-30'
|
||
GROUP BY brand, member_id
|
||
);
|
||
|
||
SQL73:
|
||
SELECT
|
||
a.perYear "年份",
|
||
a.member_count_t AS "活跃会员数量",
|
||
ROUND(a.member_count_t /
|
||
CASE
|
||
WHEN a.perYear = '2022' THEN b.count_2022
|
||
WHEN a.perYear = '2023' THEN b.count_2023
|
||
WHEN a.perYear = '2024' THEN b.count_2024
|
||
WHEN a.perYear = '2025' THEN b.count_20250630
|
||
END
|
||
, 4) AS "活跃会员占比"
|
||
FROM (SELECT perYear, SUM(member_count) AS member_count_t
|
||
FROM (SELECT SUBSTR(change_time, 1, 4) AS perYear, brand, COUNT(DISTINCT member_id) AS member_count
|
||
FROM dwd_basic_all_vip_point_dd
|
||
WHERE change_kind NOT IN ('9', '19', '70', '80', '60') -- 去除人工增减,和积分清零
|
||
AND change_time <> '' AND SUBSTR(change_time, 1, 10) >= '2022-01-01' AND SUBSTR(change_time, 1, 10) <= '2025-06-30'
|
||
GROUP BY SUBSTR(change_time, 1, 4), brand
|
||
) GROUP BY perYear
|
||
) a, (
|
||
SELECT
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 4) < '2023' THEN member_id END) AS count_2022,
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 4) < '2024' THEN member_id END) AS count_2023,
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 4) < '2025' THEN member_id END) AS count_2024,
|
||
COUNT(CASE WHEN SUBSTR(member_register_time_t, 1, 10) <= '2025-06-30' THEN member_id END) AS count_20250630
|
||
FROM (
|
||
SELECT brand, member_id, MIN(member_register_time) AS member_register_time_t
|
||
FROM dwd_basic_all_vip_info_dd
|
||
WHERE member_register_time <= '2025-06-30'
|
||
GROUP BY brand, member_id
|
||
)
|
||
) b
|
||
ORDER BY a.perYear;
|
||
|
||
SQL74:
|
||
SELECT perYear AS "年份", SUM(member_count) AS "新增会员数量"
|
||
FROM (SELECT SUBSTR(member_register_time, 1, 4) AS perYear, brand, COUNT(DISTINCT member_id) AS member_count
|
||
FROM dwd_basic_all_vip_info_dd
|
||
WHERE member_register_time >= '2022-01-01' AND member_register_time <= '2025-06-30'
|
||
GROUP BY SUBSTR(member_register_time, 1, 4), brand
|
||
) GROUP BY perYear
|
||
ORDER BY perYear;
|
||
|
||
SQL75:
|
||
SELECT perYear AS "年份", SUM(member_count) AS "注销会员数量"
|
||
FROM (SELECT SUBSTR(member_logout_time, 1, 4) AS perYear, brand, COUNT(DISTINCT member_id) AS member_count
|
||
FROM dwd_basic_all_vip_write_off_log_dd
|
||
WHERE parseDateTimeBestEffort(member_logout_time) >= '2022-01-01 00:00:00' AND parseDateTimeBestEffort(member_logout_time) <= '2025-06-30 23:59:59'
|
||
GROUP BY SUBSTR(member_logout_time, 1, 4), brand
|
||
) GROUP BY perYear
|
||
ORDER BY perYear;
|
||
|
||
SQL76:
|
||
SELECT SUBSTR(change_time, 1, 4) AS "年份", SUM(toDecimal32(point_change, 2)) AS "新增积分数量"
|
||
FROM dwd_basic_all_vip_point_dd
|
||
WHERE toDecimal32(point_change, 2) > 0 AND change_time <> '' AND SUBSTR(change_time, 1, 10) >= '2022-01-01' AND SUBSTR(change_time, 1, 10) <= '2025-06-30' AND change_kind <> '60'
|
||
GROUP BY SUBSTR(change_time, 1, 4)
|
||
ORDER BY SUBSTR(change_time, 1, 4);
|
||
|
||
SQL77:
|
||
SELECT SUBSTR(change_time, 1, 4) AS "年份", SUM(toDecimal32(point_change, 2)) AS "消耗积分数量"
|
||
FROM dwd_basic_all_vip_point_dd
|
||
WHERE toDecimal32(point_change, 2) < 0 AND change_time <> '' AND SUBSTR(change_time, 1, 10) >= '2022-01-01' AND SUBSTR(change_time, 1, 10) <= '2025-06-30' AND change_kind <> '60'
|
||
GROUP BY SUBSTR(change_time, 1, 4)
|
||
ORDER BY SUBSTR(change_time, 1, 4);
|
||
|
||
SQL78:
|
||
SELECT SUBSTR(change_time, 1, 4) AS "年份", SUM(toDecimal32(point_change_t, 2)) AS "清零积分数量"
|
||
FROM (SELECT change_time, CASE WHEN toDecimal32(point_change, 2) > 0 THEN -toDecimal32(point_change, 2) ELSE toDecimal32(point_change, 2) END AS point_change_t
|
||
FROM dwd_basic_all_vip_point_dd
|
||
WHERE change_time <> '' AND SUBSTR(change_time, 1, 10) >= '2022-01-01' AND SUBSTR(change_time, 1, 10) <= '2025-06-30' AND change_kind = '60'
|
||
)
|
||
GROUP BY SUBSTR(change_time, 1, 4)
|
||
ORDER BY SUBSTR(change_time, 1, 4); |