EXPLAIN SELECT
report_time,
shop_name,
order_no,
rela_money,
( CASE erp_times WHEN 1 THEN STATUS ELSE - 4 END ) AS STATUS
,
store_money,
is_same,
order_status,
warehouse
,
kd_number
,
kd_company
,
product_number
,
product_name
,
create_time,
update_time,
memo,
reportTimes AS times,
store_times AS store_times
FROM
(
SELECT
CASE
count( 1 )
WHEN 1 THEN
bed.send_warehouse ELSE GROUP_CONCAT( bed.send_warehouse SEPARATOR "/" )
END AS warehouse,
CASE
count( 1 )
WHEN 1 THEN
bed.courier_number ELSE GROUP_CONCAT( bed.courier_number SEPARATOR "/" )
END AS kd_number,
CASE
count( 1 )
WHEN 1 THEN
bed.courier_company ELSE GROUP_CONCAT( bed.courier_company SEPARATOR "/" )
END AS kd_company,
CASE
count( 1 )
WHEN 1 THEN
bed.product_number ELSE GROUP_CONCAT( bed.product_number SEPARATOR "/" )
END AS product_number,
CASE
count( 1 )
WHEN 1 THEN
bed.product_name ELSE GROUP_CONCAT( bed.product_name SEPARATOR "/" )
END AS product_name,
newbb.memo,
newbb.report_time,
newbb.shop_name,
newbb.order_no,
newbb.rela_money,
newbb.STATUS,
newbb.store_money,
newbb.is_same,
newbb.order_status,
newbb.create_time,
newbb.update_time,
newbb.reportTimes,
newbb.store_times AS store_times,
CASE
WHEN bed.send_warehouse IS NULL THEN
0 ELSE count( 1 )
END AS erp_times
FROM
(
SELECT
brd.remark AS memo,
brd.report_time AS report_time
,
brd.shop_name AS shop_name
,
brd.order_no AS order_no
,
brd.buyer_actually_pay_cost AS rela_money
,
brd.STATUS AS STATUS
,
CASE
count( 1 )
WHEN 1 THEN
bsd.actually_pay ELSE GROUP_CONCAT( bsd.actually_pay SEPARATOR "/" )
END AS store_money,
CASE
bsd.actually_pay
WHEN brd.buyer_actually_pay_cost THEN
'TRUE' ELSE 'FALSE'
END AS is_same
,
bsd.order_status AS order_status
,
brd.create_time AS create_time,
brd.update_time AS update_time,
brd.reportTimes AS reportTimes,
CASE
WHEN bsd.order_status IS NULL THEN
0 ELSE count( 1 )
END AS store_times
FROM
(
SELECT
remark,
report_time,
shop_name,
order_no,
buyer_actually_pay_cost,
STATUS,
create_time,
update_time,
dump,
count( 1 ) AS reportTimes
FROM
biz_report_data
WHERE
1 = 1
AND report_time >= '2020-11-01'
AND report_time <= '2020-11-01'
GROUP BY
order_no
) brd
LEFT JOIN biz_store_data bsd ON brd.order_no = bsd.order_no
WHERE
brd.STATUS != 0
GROUP BY
order_no
) newbb
LEFT JOIN biz_erp_data bed ON order_no = bed.on_order_no
GROUP BY
order_no
) groupView
WHERE
1 = 1
AND order_no IS NOT NULL
AND store_times > 1
GROUP BY
order_no
ORDER BY
report_time ASC
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/244959.html
標籤:疑難問題
上一篇:求購BOSE SOUNDTOUCH 30III 升級韌體及方法
下一篇:LDA
