帆软用户FWiAjHCl42(提问者)SELECT
\'出厂检测\' as \'精细管理场景\',
COUNT(A.product_name),
sum(a.cn),
COUNT(B.product_name),
sum(b.cn),
sum(b.money_amount)/10000,
sum(b.amount_involved)
from
(
SELECT
product_name,
count(*) as cn,
import_time
FROM
l_factory_detection_detail
where 1=1
GROUP BY
product_name
) a
LEFT JOIN (
SELECT
product_name,
count(*) as cn,
sum(money_amount) money_amount,
sum(amount_involved) amount_involved ,
import_time
FROM
(select m.product_name,m.money_amount,m.inspection_result,m.detection_date,n.amount_involved,m.import_time from l_factory_detection_detail m left join l_quality_problem_detection_detail n on m.order_no=n.order_no) c
WHERE
inspection_result = \'不合格\'
GROUP BY
product_name
) b ON a.product_name = b.product_name