Inventory value by warehouse
Stock quantity multiplied by the item average cost, totalled per warehouse.
Tool
SELECT T0.WhsCode, SUM(T0.OnHand) AS Quantity, SUM(T0.OnHand * T1.AvgPrice) AS StockValue FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.OnHand <> 0 GROUP BY T0.WhsCode ORDER BY StockValue DESC
SELECT T0."WhsCode", SUM(T0."OnHand") AS "Quantity", SUM(T0."OnHand" * T1."AvgPrice") AS "StockValue" FROM OITW T0 INNER JOIN OITM T1 ON T0."ItemCode" = T1."ItemCode" WHERE T0."OnHand" <> 0 GROUP BY T0."WhsCode" ORDER BY "StockValue" DESC
What this query answers
For the month-end close or the insurance renewal, the accountant needs the stock value held in each warehouse. It gives one number per warehouse that can be compared with the inventory accounts in the balance sheet.
Need quantities instead of value? The stock by warehouse query shows on hand, committed and on order per warehouse.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| WhsCode | Quantity | StockValue |
|---|---|---|
| 01 | 4820 | 186450 |
| 02 | 1310 | 52380.5 |
| 03 | 260 | 9875 |
SQL Server vs SAP HANA
SUM(OnHand * AvgPrice) translates directly; HANA only needs the quoted names "OnHand" and "AvgPrice" and the quoted aliases in ORDER BY.
Common errors and fixes
- Value does not match the Inventory Audit Report: OITM.AvgPrice is the item-level average. If your company manages item cost per warehouse, use OITW.AvgPrice (T0.AvgPrice) instead. FIFO and standard-cost items can also differ from the audit report.
- Quantity total is meaningless: It adds up units of different items and units of measure. Use it only as a rough indicator; the StockValue column is the real figure.
Need this report built into SAP Business One?
A saved query answers the question once. We build SAP Business One reports and dashboards on SQL Server and HANA, and you own the files. Or hire a remote SAP Business One developer for the whole job, fixed price per phase.
Related queries
Table reference: OITW table (Item stock per warehouse) · OITM table (Items (item master data))
Three steps, no signup
Copy the right version
Use the SQL Server tab for MS SQL databases and the HANA tab for SAP B1 on HANA.
Open Query Generator
In SAP Business One go to Tools → Queries → Query Generator, paste and click Execute.
Save and share
Click Save, pick a category and give the query a name. Your team can run it from Query Manager.
Questions about this tool
How do I run the inventory value by warehouse query in SAP Business One?
Copy the version that matches your database, open Tools → Queries → Query Generator, paste it in the SQL box and click Execute. Save it to reuse it later.
Which tables does this query use?
It reads OITW, OITM from the standard SAP Business One schema. No user-defined fields are needed.
Can this be turned into a dashboard or alert?
Yes. We turn queries into Crystal reports, Excel reports that refresh themselves, SAP B1 alerts or WhatsApp messages for managers.
Built for SAP Business One teams
Need this inside SAP Business One?
We build add-ons, reports and integrations for SAP B1 on SQL Server and HANA. Tell us what you need and get a fixed price, usually within 24 hours.
