把两个查询子句直接当作表查询,语句为:
select t1.ny,t1.zqsj,t1.yy,t2.kjs
from (select ny, sum(zqsj) zqsj, AVG(yy) yy from yyy GROUP BY ny) t1
left join
(select ny,count(jh) kjs,zqsj from yyy GROUP BY ny HAVING zqsj>0) t2
on t1.ny=t2.ny
把两个查询子句直接当作表查询,语句为:
select t1.ny,t1.zqsj,t1.yy,t2.kjs
from (select ny, sum(zqsj) zqsj, AVG(yy) yy from yyy GROUP BY ny) t1
left join
(select ny,count(jh) kjs,zqsj from yyy GROUP BY ny HAVING zqsj>0) t2
on t1.ny=t2.ny