我有这个咨询,我想知道哪个更好优化?这种做法显示了具有每个状态的总计划和具有每个状态的总草图
SELECT l.cve_ent,
COUNT(IF (plano='S',1,NULL)) PLR,
COUNT(IF (plano='C',1,NULL)) CROQUIS
FROM
(localidades l
LEFT JOIN
statusloc s
ON (l.cve_ent=s.cve_ent AND l.cve_mun =s.cve_mun AND l.cve_loc= s.cve_loc))
LEFT JOIN
cigel13 c
ON (l.cve_ent=C.cve_ent AND l.cve_mun =c.cve_mun AND l.cve_loc= c.cve_loc)
WHERE l.esquema='03'
GROUP BY CVE_ENT
或者
SELECT l.cve_ent,
COUNT(*) PLR,
FROM
(localidades l
LEFT JOIN
statusloc s
ON (l.cve_ent=s.cve_ent AND l.cve_mun =s.cve_mun AND l.cve_loc= s.cve_loc))
LEFT JOIN
cigel13 c
ON (l.cve_ent=C.cve_ent AND l.cve_mun =c.cve_mun AND l.cve_loc= c.cve_loc)
WHERE l.esquema='03'
GROUP BY cve_ent,plano