当前位置: 代码迷 >> Oracle管理 >> 这条语句count(*)为何得不到select出来的总行数?解决思路
  详细解决方案

这条语句count(*)为何得不到select出来的总行数?解决思路

热度:5   发布时间:2016-04-24 05:17:02.0
这条语句count(*)为何得不到select出来的总行数???
这条语句count(*)为何得不到select出来的总行数???
SELECT count(*),
 we.wip_entity_name,
 MSI2.SEGMENT1,
 sum(WRO.REQUIRED_QUANTITY) QTY,
 MSI.PRIMARY_UNIT_OF_MEASURE UOM,
 wro.QUANTITY_PER_ASSEMBLY
  FROM WIP.WIP_DISCRETE_JOBS WDJ,
  WIP.WIP_REQUIREMENT_OPERATIONS WRO,
  INV.MTL_SYSTEM_ITEMS MSI,
  WIP.WIP_OPERATIONS WO,
  INV.MTL_SYSTEM_ITEMS MSI2
  ,wip.wip_entities we
 WHERE WDJ.STATUS_TYPE IN (1, 3, 6)
  AND WDJ.WIP_ENTITY_ID = WRO.WIP_ENTITY_ID
  AND WRO.ORGANIZATION_ID = 4
  AND MSI.ORGANIZATION_ID = 4
  AND WRO.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID  
  AND WO.WIP_ENTITY_ID = WRO.WIP_ENTITY_ID
  AND WRO.OPERATION_SEQ_NUM = WO.OPERATION_SEQ_NUM
  AND nvl(WRO.QUANTITY_ISSUED, 0) = 0
  and nvl(WRO.REQUIRED_QUANTITY, 0) > 0
  AND MSI2.ORGANIZATION_ID = 4
  AND WDJ.PRIMARY_ITEM_ID = MSI2.INVENTORY_ITEM_ID
  and wdj.wip_entity_id=we.wip_entity_id  
  and substr(MSI.SEGMENT1,1,1) in ('7')
  and MSI.SEGMENT1 like '7190-020160%'
  group by
  we.wip_entity_name,
  MSI2.SEGMENT1,
  MSI.PRIMARY_UNIT_OF_MEASURE ,
  wro.QUANTITY_PER_ASSEMBLY
结果如下:
count(*) wip_entity_name SEGMENT1 qty uom QUANTITY_PER_ASSEMBLY
1 FJ2012060501 3459-403180 18.6 kg 9.3
1 FJ2012060502 3459-403180 18.6 kg 9.3
明明是行数是两行,我希望能得到行数2,但count(*)却是1,应该怎么改语句啊

------解决方案--------------------
group by 分组统计 统计的是每组的行数
------解决方案--------------------
你把 group by 中的wip_entity_name 去掉,就应该是2了,,,
  相关解决方案