我想彙總一些結果,但我沒有任何運氣。下面是我使用的SQL與實際輸出:它生產這個數據從SQL結果彙總結果
SQL語句:
SELECT
i.inventory_item_id,
i.organization_id,
sum(primary_transaction_quantity) as on_hand_qty
FROM mtl_onhand_quantities_detail oqd, mtl_system_items_b i
WHERE oqd.inventory_item_id = i.inventory_item_id
AND oqd.inventory_item_id = 117567 -- just used to restrict results for this example
AND i.organization_id = :p_organization_id
AND oqd.organization_id = i.organization_id
GROUP BY i.inventory_item_id, i.organization_id, primary_transaction_quantity
INVENTORY_ITEM_ID,ORGANIZATION_ID,ON_HAND_QTY
117567,7651,2
117567,7651,1
我需要什麼返回:
INVENTORY_ITEM_ID,ORGANIZATION_ID,ON_HAND_QTY
117567,7651,3
基本上,它需要總結的on_hand_qty
並且只返回一個結果行,如果inventory_item_id
和organization_id
是相同的。任何幫助是極大的讚賞!從組
什麼是:p_organization_id? – Zane
您還使用了哪些DBMS? – Zane
:p_organization_id是您如何在Oracle中定義用戶可以在報表運行時輸入的參數。它們輸入的值被替換,其中:p_organization_id在代碼中。 – Jedis