{"database": "fishbowl_archive", "table": "dataexport", "rows": [[20, "SELECT\r\n  lg.name AS `Location Group`,\r\n  p.num AS `Part Number`,\r\n  p.description AS `Part Description`,\r\n\r\n  /* Reorder levels (will be NULL when No ROP/OUL is true) */\r\n  pr.reorderPoint AS `Reorder Point`,\r\n  pr.orderUpToLevel AS `Order Up To`,\r\n\r\n  /* On Hand per Forecast definition: OnHand subtracts Not Available */\r\n  (COALESCE(qi.qtyOnHand, 0) - COALESCE(qi.qtyNotAvailable, 0)) AS `On Hand`,  -- [1](https://help.fishbowlinventory.com/resource/advancedreports)[4](https://fishbowlhelp.com/files/database/tables/qtyinventory.html)\r\n\r\n  /* On Order = totals across sources (PO + SO + TO + MO) */\r\n  (COALESCE(qi.qtyOnOrderPO, 0)\r\n   + COALESCE(qi.qtyOnOrderSO, 0)\r\n   + COALESCE(qi.qtyOnOrderTO, 0)\r\n   + COALESCE(qi.qtyOnOrderMO, 0)\r\n  ) AS `On Order`,  -- [4](https://fishbowlhelp.com/files/database/tables/qtyinventory.html)\r\n\r\n  /* Allocated = totals across sources (PO + SO + TO + MO) */\r\n  (COALESCE(qi.qtyAllocatedPO, 0)\r\n   + COALESCE(qi.qtyAllocatedSO, 0)\r\n   + COALESCE(qi.qtyAllocatedTO, 0)\r\n   + COALESCE(qi.qtyAllocatedMO, 0)\r\n  ) AS `Allocated`,  -- [4](https://fishbowlhelp.com/files/database/tables/qtyinventory.html)\r\n\r\n  /* Shortage Qty (Include No ROP/OUL):\r\n     Needed = OrderUpTo - OnOrder - OnHand + Allocated\r\n     Shortage = max(Needed, 0)\r\n     For No ROP/OUL parts, OrderUpTo is treated as 0 via COALESCE.\r\n  */\r\n  GREATEST(\r\n    (\r\n      COALESCE(pr.orderUpToLevel, 0)\r\n      - (COALESCE(qi.qtyOnOrderPO, 0)\r\n         + COALESCE(qi.qtyOnOrderSO, 0)\r\n         + COALESCE(qi.qtyOnOrderTO, 0)\r\n         + COALESCE(qi.qtyOnOrderMO, 0)\r\n        )\r\n      - (COALESCE(qi.qtyOnHand, 0) - COALESCE(qi.qtyNotAvailable, 0))\r\n      + (COALESCE(qi.qtyAllocatedPO, 0)\r\n         + COALESCE(qi.qtyAllocatedSO, 0)\r\n         + COALESCE(qi.qtyAllocatedTO, 0)\r\n         + COALESCE(qi.qtyAllocatedMO, 0)\r\n        )\r\n    ),\r\n    0\r\n  ) AS `Shortage Qty`  -- [1](https://help.fishbowlinventory.com/resource/advancedreports)\r\n\r\nFROM qtyinventory qi\r\nJOIN part p\r\n  ON p.id = qi.partId\r\nJOIN locationgroup lg\r\n  ON lg.id = qi.locationGroupId\r\n\r\n/* LEFT JOIN is what \u201cincludes No ROP/OUL\u201d rows */\r\nLEFT JOIN partreorder pr\r\n  ON pr.partId = p.id\r\n AND pr.locationGroupId = lg.id  -- [2](https://fishbowlhelp.com/files/database/tables/partreorder.html)[4](https://fishbowlhelp.com/files/database/tables/qtyinventory.html)\r\n\r\nWHERE\r\n  /* Only include parts that do NOT have a BOM */\r\n  (p.defaultBomId IS NULL OR p.defaultBomId = 0)  -- [5](https://fishbowlhelp.com/files/database/tables/bom.html)\r\n\r\nORDER BY lg.name, p.num\r\n", "2026-02-24 16:00:52.049000", "2026-02-24 16:00:52.049000", "Below is the updated query (NO BOM parts only) with Shortage Qty and No ROP/OUL included.", 17, "Shortage Report"]], "columns": ["id", "dataQuery", "dateCreated", "dateLastModified", "description", "lastChangedUserId", "name"], "primary_keys": ["id"], "primary_key_values": ["20"], "units": {}, "query_ms": 1.6427160007879138}