Differences
This shows you the differences between two versions of the page.
control_sql_-_check_all_inventory_levels_v_all_inventory_logs [2019/01/27 11:28] 127.0.0.1 external edit |
control_sql_-_check_all_inventory_levels_v_all_inventory_logs [2019/02/01 10:08] (current) shendrix [SQL #1 - Identify Discrepencies] |
||
---|---|---|---|
Line 18: | Line 18: | ||
====== SQL #1 - Identify Discrepencies ====== | ====== SQL #1 - Identify Discrepencies ====== | ||
- | |||
- | |||
<code sql> | <code sql> | ||
SELECT * FROM( | SELECT * FROM( | ||
SELECT | SELECT | ||
- | INV.ID | + | INV.ID |
- | , INV.PartID | + | , INV.PartID |
, P.ItemName | , P.ItemName | ||
- | , SUM(INVL.QuantityBilled) | + | , SUM(INVL.QuantityBilled) |
- | , SUM(INVL.QuantityReceivedOnly) | + | , SUM(INVL.QuantityReceivedOnly) |
- | , SUM(INVL.QuantityOnHand) | + | , SUM(INVL.QuantityOnHand) |
- | , SUM(INVL.QuantityReserved) | + | , SUM(INVL.QuantityReserved) |
- | , SUM(INVL.QuantityAvailable) | + | , SUM(INVL.QuantityAvailable) |
- | , SUM(INVL.QuantityOnOrder) | + | , SUM(INVL.QuantityOnOrder) |
- | , SUM(INVL.QuantityExpected) | + | , SUM(INVL.QuantityExpected) |
- | , INV.QuantityBilled | + | , INV.QuantityBilled |
- | , INV.QuantityReceivedOnly | + | , INV.QuantityReceivedOnly |
- | , INV.QuantityOnHand | + | , INV.QuantityOnHand |
- | , INV.QuantityReserved | + | , INV.QuantityReserved |
- | , INV.QuantityAvailable | + | , INV.QuantityAvailable |
- | , INV.QuantityOnOrder | + | , INV.QuantityOnOrder |
- | , INV.QuantityExpected | + | , INV.QuantityExpected |
FROM InventoryLog INVL | FROM InventoryLog INVL | ||
LEFT JOIN Inventory INV ON INV.ID = INVL.InventoryID | LEFT JOIN Inventory INV ON INV.ID = INVL.InventoryID | ||
LEFT JOIN Part P ON P.ID = INV.PartID | LEFT JOIN Part P ON P.ID = INV.PartID | ||
- | WHERE | + | WHERE |
INV.ID IS NOT NULL | INV.ID IS NOT NULL | ||
- | GROUP BY | + | GROUP BY |
P.ItemName | P.ItemName | ||
, INV.PartID | , INV.PartID | ||
Line 58: | Line 56: | ||
, INV.ID | , INV.ID | ||
) Tmp | ) Tmp | ||
- | WHERE | + | WHERE |
- | (ROUND(QuantityBilled, | + | (ROUND(QuantityBilled, |
- | OR (ROUND(QuantityReceivedOnly, | + | OR (ROUND(QuantityReceivedOnly, |
- | OR (ROUND(QuantityOnHand, | + | OR (ROUND(QuantityOnHand, |
- | OR (ROUND(QuantityReserved, | + | OR (ROUND(QuantityReserved, |
- | OR (ROUND(QuantityAvailable, | + | OR (ROUND(QuantityAvailable, |
- | OR (ROUND(QuantityOnOrder, | + | OR (ROUND(QuantityOnOrder, |
- | OR (ROUND(QuantityExpected, | + | OR (ROUND(QuantityExpected, |
</ | </ | ||
- | |||