{"database": "fishbowl_archive", "table": "dataexport", "rows": [[18, "SELECT\r\n  p.num AS PartNum,\r\n  CONCAT(lg.name,'-',l.name) AS DisplayLocation,\r\n  t.num AS TagNum,\r\n  t.qty,\r\n  t.qtyCommitted,\r\n  (t.qty - IFNULL(t.qtyCommitted,0)) AS AvailableQty,\r\n\r\n  ri.dateReceived AS ReceiptDate,\r\n  poi.unitCost    AS PoUnitCost,\r\n\r\n  il_first.eventDate AS FirstInvEventDate,\r\n  il_first.cost      AS InvLogCost,\r\n\r\n  COALESCE(poi.unitCost, il_first.cost) AS ChosenCost\r\n\r\nFROM part p\r\nJOIN tag t ON t.partId = p.id\r\nJOIN location l ON l.id = t.locationId\r\nJOIN locationgroup lg ON lg.id = l.locationGroupId\r\n\r\nLEFT JOIN receiptitem ri ON ri.tagId = t.id\r\nLEFT JOIN poitem poi     ON poi.id = ri.poItemId\r\n\r\nLEFT JOIN (\r\n    SELECT endTagNum, endLocationId, partId, cost, eventDate\r\n    FROM (\r\n        SELECT\r\n            il.endTagNum, il.endLocationId, il.partId, il.cost, il.eventDate,\r\n            ROW_NUMBER() OVER (\r\n                PARTITION BY il.endTagNum, il.endLocationId\r\n                ORDER BY il.eventDate ASC, il.id ASC\r\n            ) AS rn\r\n        FROM inventorylog il\r\n        WHERE il.changeQty > 0\r\n          AND il.endTagNum IS NOT NULL\r\n    ) z\r\n    WHERE z.rn = 1\r\n) il_first\r\n  ON il_first.endTagNum = t.num\r\n AND il_first.endLocationId = t.locationId\r\n AND il_first.partId = t.partId\r\n\r\nWHERE p.num = '16204-17'\r\n  AND (CONCAT(lg.name,'-',l.name) = 'Main-ISI' OR l.name = 'Main-ISI')\r\n  AND t.qty > 0\r\n\r\nORDER BY COALESCE(ri.dateReceived, il_first.eventDate, t.dateCreated) ASC, t.num ASC;", "2026-02-18 09:31:33.105000", "2026-02-18 09:31:33.105000", "", 17, "Return inventory location by PN"]], "columns": ["id", "dataQuery", "dateCreated", "dateLastModified", "description", "lastChangedUserId", "name"], "primary_keys": ["id"], "primary_key_values": ["18"], "units": {}, "query_ms": 2.0361209753900766}