select 
       a1.系列,
       a1.年月,
       a1.产地,
       a1.产量,
       (select a2.故障数
          from (select 系列, 产地, count(柴油机序号) as 故障数
                  from crm维修数据
                 where 生产年月 = '2008-09'
                   and 故障年月 >= '2008-09'
                   and 故障年月 <=
                       to_char(add_months(to_date('2008-09', 'yyyy-mm'), +3),
                               'yyyy-mm')
                 group by 系列, 产地) a2
         where a2.系列 = a1.系列
           and a2.产地 = a1.产地) as 三个月项次
  from (select 系列, 年月, 产地, sum(产量) as 产量
          from crm产量信息
         where 年月 = '2008-09'
         group by 系列, 年月, 产地) a1其中,crm产量信息,crm维修数据 均来自外部DBLINK : HISORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM运行报错如下:
              ORA-00979 不是GROUP BY 表达式
              ORA-02063 紧接着line (起自HISORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM)
请问是什么原因??

解决方案 »

  1.   

    最后一行“group by 系列, 年月, 产地”改为“group by 系列, 年月, 产地, 产量” 试试
      

  2.   

    select 
          a1.系列, 
          a1.年月, 
          a1.产地, 
          a1.产量, 
          (select a2.故障数 
              from (select 系列, 产地, count(柴油机序号)  故障数 
                      from crm维修数据 
                    where 生产年月 = '2008-09' 
                      and 故障年月 >= '2008-09' 
                      and 故障年月 <= 
                          to_char(add_months(to_date('2008-09', 'yyyy-mm'), +3), 
                                  'yyyy-mm') 
                    group by 系列, 产地) a2 
            where a2.系列 = a1.系列 
              and a2.产地 = a1.产地)  三个月项次 
      from (select 系列, 年月, 产地, sum(产量) 产量 
              from crm产量信息 
            where 年月 = '2008-09' 
            group by 系列, 年月, 产地) a1 
    试试这个
      

  3.   

    第2个错是你的表名有问题。DBLINK出错。第1个。楼主可以一个个拆分运行试下