Slow-moving items (no sales in 90 days)
Items with stock on hand that have not been invoiced in the last 90 days.
Tool
SELECT T0.ItemCode, T0.ItemName, T0.OnHand, T0.AvgPrice, T0.OnHand * T0.AvgPrice AS StockValue FROM OITM T0 WHERE T0.OnHand > 0 AND NOT EXISTS ( SELECT 1 FROM INV1 T1 INNER JOIN OINV T2 ON T1.DocEntry = T2.DocEntry WHERE T1.ItemCode = T0.ItemCode AND T2.DocDate >= DATEADD(day, -90, GETDATE()) ) ORDER BY StockValue DESC
SELECT T0."ItemCode", T0."ItemName", T0."OnHand", T0."AvgPrice", T0."OnHand" * T0."AvgPrice" AS "StockValue" FROM OITM T0 WHERE T0."OnHand" > 0 AND NOT EXISTS ( SELECT 1 FROM INV1 T1 INNER JOIN OINV T2 ON T1."DocEntry" = T2."DocEntry" WHERE T1."ItemCode" = T0."ItemCode" AND T2."DocDate" >= ADD_DAYS(CURRENT_TIMESTAMP, -90) ) ORDER BY "StockValue" DESC
What this query answers
Before planning a clearance sale, the operations manager wants to know which items are taking up shelf space and money without selling. This lists stocked items with no A/R invoice in 90 days, the most capital tied up first.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| ItemCode | ItemName | OnHand | AvgPrice | StockValue |
|---|---|---|---|---|
| A00021 | Office Chair Deluxe | 18 | 145 | 2610 |
| A00034 | Desk Lamp LED | 60 | 22.5 | 1350 |
| A00040 | Whiteboard 90x60 | 12 | 48 | 576 |
| A00052 | Cable Organizer | 75 | 3.2 | 240 |
SQL Server vs SAP HANA
DATEADD(day, -90, GETDATE()) becomes ADD_DAYS(CURRENT_TIMESTAMP, -90) inside the NOT EXISTS subquery. The correlated subquery itself works the same on HANA.
Common errors and fixes
- An item counts as sold because of a cancelled invoice: The subquery does not filter cancelled invoices. Add AND T2.CANCELED = 'N' inside NOT EXISTS.
- Items shipped on deliveries but not yet invoiced are listed: Only invoices are checked. Add an OR EXISTS on DLN1/ODLN if your invoicing runs well after delivery.
- Newly received items are mixed in: NOT EXISTS also matches items that were never invoiced, such as stock that arrived last week. Add AND T0.CreateDate < DATEADD(day, -90, GETDATE()) to leave out new items.
Need this report built into SAP Business One?
A saved query answers the question once. We build Crystal Reports and Power BI dashboards for SAP Business One 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: OITM table (Items (item master data)) · INV1 table (A/R Invoice (lines)) · OINV table (A/R Invoice (header)) · OINM table (Warehouse Journal (inventory audit))
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 slow-moving items (no sales in 90 days) 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 OITM, INV1, OINV 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.
