将结果集当作数据表来用

SELECT p.id as id,
MAX(p.provider_name) as name,
COUNT(r.id_goods) as counts,
SUM(r.count_id) as repairCount,
SUM(r.sum_repair) as sums 

FROM t_itsm_erp_provider p,
t_rs_assetcert_info t,

(SELECT t.id_goods, COUNT(t.id_goods) AS count_id ,SUM(t.sum_repair) AS sum_repair FROM t_rs_repair t WHERE 1=1  GROUP BY t.id_goods) r

WHERE t.id_goods = r.id_goods AND p.id = t.id_maintenance AND p.type = 1 GROUP BY p.id

你可能感兴趣的:(数据)