减去同一列中的值

时间:2014-05-09 23:01:57

标签: sql oracle

Wip Return Trouble

在咨询物料交易时的批次详细信息中,显示“WIP ISSUE(2)”和“WIP RETURN(2)”,因此当我恢复数据时,我不希望这些数字是显示。 (wip问题和wip返回)

SELECT
  mmt.subinventory_code                    subinventario,
  msib.segment1                            segmento,
  msib.description                         descripción,
  SUM(mmln.transaction_quantity)           transacción_primaria,
  mmt.transaction_uom                      medida_primaria,
  SUM(mmln.secondary_transaction_quantity) transacción_secundaria,
  mmt.secondary_uom_code                   medida_secundaria,
  mtl.grade_code                           grado,
  mmt.transaction_type_id,
  mmt.transaction_source_id
FROM mtl_transaction_lot_numbers mmln,
  mtl_material_transactions mmt,
  mtl_system_items_b msib,
  mtl_lot_numbers mtl
WHERE mmt.transaction_source_id IN (
  SELECT bh.batch_id
  FROM gme.gme_batch_header bh, gme.gme_material_details det
  WHERE bh.batch_id = det.batch_id
        AND det.line_type = 1
        AND (TRUNC(actual_start_date) BETWEEN :p_start_date AND TO_DATE(:p_end_date))
        AND bh.organization_id = 269)
      AND mmt.organization_id = 269
      AND mmt.transaction_type_id IN (44, 35, 43, 17)
      AND mmt.transaction_id = mmln.transaction_id
      AND mmt.inventory_item_id = mmln.inventory_item_id
      AND mmt.organization_id = mmln.organization_id
      AND msib.inventory_item_id = mmt.inventory_item_id
      AND msib.organization_id = mmt.organization_id
      AND mtl.lot_number = mmln.lot_number
      AND mtl.organization_id = mmln.organization_id
GROUP BY mmt.subinventory_code,
  msib.segment1,
  msib.description,
  mmt.transaction_uom,
  mmt.secondary_uom_code,
  mtl.grade_code,
  mmt.transaction_type_id,
  mmt.transaction_source_id
ORDER BY mmt.transaction_type_id

0 个答案:

没有答案