下面的SQL在Oracle11g下可以正常执行,但在Oracle9i 里面会报错
ORA-00979: 不是 GROUP BY 表达式
00979. 00000 -  "not a GROUP BY expression"
SELECT 
nvl(A.CallinagtNUMLackIvr,0) as CallinagtNUMLackIvr,
nvl(C.CalledagtNUM,0) as CalledagtNUM,
nvl(A.serviceNo,C.serviceno) as serviceno,
nvl(A.timePeriod,C.timePeriod) as timePeriod
FROM
(
      SELECT 
          COUNT(distinct callid) AS CallinagtNUMLackIvr,
          trunc(callend,'HH24') as timePeriod,
          serviceNo,
          (to_char(trunc(callend,'HH24'),'YYYYMMDDHH24MISS')+serviceno) as ids 
FROM tbilllog1
WHERE (devicetype = 2 or (devicetype = 1 and callidnum = -1))
AND callend >= to_date('20130101000000','YYYYMMDDHH24MISS')
      AND callend <to_date('20130102000000','YYYYMMDDHH24MISS')
AND calltype IN (0,5,13)
AND serviceno in (111,112,113,114,115)   
group by 
    serviceNo,trunc(callend,'HH24')
 )a,
 (
      select count(DISTINCT callid) AS CalledagtNUM,trunc(callend,'HH24') as timePeriod,serviceNo,(to_char(trunc(callend,'HH24'),'YYYYMMDDHH24MISS')+serviceno) as ids 
from tbilllog1
where callend >= to_date('20130101000000','YYYYMMDDHH24MISS')
AND callend <to_date('20130102000000','YYYYMMDDHH24MISS')
      and CALLTYPE in (0,5,13)
      and Callend > Ackbegin
      and DEVICETYPE = 2
      and SERVICENO in (111,112,113,114,115)
      group by 
        serviceNo,trunc(callend,'HH24')
)C where A.ids = C.ids 
         oraclesqloracle9ioracle11ggroup by