以下语句为何报错?RA-00979: not a GROUP BY expression
以下语句正常得到结果:
SELECT a.sljg,b.jgmc,substr(a.tdj,1,4) ,C.XSJMC ,count(1)
FROM TYJMX a,TJGB b,TXSJMCYB c
WHERE a.sljg=b.jgbh and C.YB=substr(a.tdj,1,4)
and a.sljg='31003800' and substr(a.tdj,1,4)<>'3100'
and a.yjzt<>'Z' and substr(a.pc,1,2)<>'CS'
group by a.sljg,b.jgmc,substr(a.tdj,1,4) ,C.XSJMC
;
但是: SELECT a.sljg,b.jgmc,substr(a.tdj,1,4) ,C.XSJMC ,count(1) ,
(SELECT COUNT(*)
FROM tyjmx d
WHERE d.sljg = a.sljg and d.tdj=a.TDJ
and d.sljg='31003800' and substr(d.tdj,1,4)<>'3100'
AND d.yjzl = 'B类邮件' )
FROM TYJMX a,TJGB b,TXSJMCYB c
WHERE a.sljg=b.jgbh and C.YB=substr(a.tdj,1,4)
and a.sljg='31003800' and substr(a.tdj,1,4)<>'3100'
and a.yjzt<>'Z' and substr(a.pc,1,2)<>'CS'
group by a.sljg,b.jgmc,substr(a.tdj,1,4) ,C.XSJMC
;
却报错:RA-00979: not a GROUP BY expression
其中d.yjzl = 'B类邮件' ) 是邮件种类中的一部分
oracle10g是支持这种写法的,求助
------解决方案-------------------- (SELECT COUNT(*)
FROM tyjmx d
WHERE d.sljg = a.sljg and d.tdj=a.TDJ
and d.sljg='31003800' and substr(d.tdj,1,4)<>'3100'
AND d.yjzl = 'B类邮件' )
这个弄个列别名
然后写到group by字句里面
------解决方案--------------------SELECT a.sljg,b.jgmc,substr(a.tdj,1,4) ,C.XSJMC ,count(1) ,
(SELECT COUNT(*)
FROM tyjmx d
WHERE d.sljg = a.sljg and d.tdj=a.TDJ
and d.sljg='31003800' and substr(d.tdj,1,4)<>'3100'
AND d.yjzl = 'B类邮件'
group by a.sljg,b.jgmc,substr(a.tdj,1,4) ,C.XSJMC)
&nb