select car.carton_no,car.carton_weight,car.update_time, nvl(count(box.packing_box_sys_id), 0) PACKED_BOX_NUM
   from PACKING_BOX box, PACKING_CARTON car
  where box.PACKING_CARTON_SYS_ID = car.PACKING_CARTON_SYS_ID
    and car.CARTON_NO = 'CN0GH911708218CF02P7'
    and box.STATUS = '1' 注 : 按理说上面的语句查出来应该只有一条数据现在报了这个异常 实在苦于经验不足 请大侠们指点下。异常消息: ORA-00937: not a single-group group function 

解决方案 »

  1.   

    你用了COUNT()分组函数
    要加GROUP BY car.carton_no,car.carton_weight,car.update_timeselect car.carton_no,car.carton_weight,car.update_time, nvl(count(box.packing_box_sys_id), 0) PACKED_BOX_NUM
       from PACKING_BOX box, PACKING_CARTON car
      where box.PACKING_CARTON_SYS_ID = car.PACKING_CARTON_SYS_ID
        and car.CARTON_NO = 'CN0GH911708218CF02P7'
        and box.STATUS = '1' 
    GROUP BY car.carton_no,car.carton_weight,car.update_time
      

  2.   

    用了分组函数,除了分组以外的列都要写在group by 子名中
      

  3.   

    --异常消息: ORA-00937: not a single-group group function
    --就是没有加group by 记得聚合函数要加group by  select car.carton_no,car.carton_weight,car.update_time, nvl(count(box.packing_box_sys_id), 0) PACKED_BOX_NUM
       from PACKING_BOX box, PACKING_CARTON car
      where box.PACKING_CARTON_SYS_ID = car.PACKING_CARTON_SYS_ID
        and car.CARTON_NO = 'CN0GH911708218CF02P7'
        and box.STATUS = '1' 
    group by car.carton_no,car.carton_weight,car.update_time