Sales by sales employee
Invoice count and net sales per sales employee for a period.
Tool
SELECT T1.SlpName, COUNT(T0.DocEntry) AS Invoices, SUM(T0.DocTotal - T0.VatSum) AS NetSales FROM OINV T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode WHERE T0.CANCELED = 'N' AND T0.DocDate BETWEEN '[%0]' AND '[%1]' GROUP BY T1.SlpName ORDER BY NetSales DESC
SELECT T1."SlpName", COUNT(T0."DocEntry") AS "Invoices", SUM(T0."DocTotal" - T0."VatSum") AS "NetSales" FROM OINV T0 INNER JOIN OSLP T1 ON T0."SlpCode" = T1."SlpCode" WHERE T0."CANCELED" = 'N' AND T0."DocDate" BETWEEN '[%0]' AND '[%1]' GROUP BY T1."SlpName" ORDER BY "NetSales" DESC
What this query answers
At month end, the finance team needs each sales employee's invoiced net sales to calculate commission, and the sales director wants to see who is ahead of target. The invoice count helps spot someone with a few large deals versus many small ones.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| SlpName | Invoices | NetSales |
|---|---|---|
| Sophie Klein | 64 | 72350 |
| Daniel Ortiz | 51 | 58120.4 |
| Laila Hassan | 38 | 41980 |
| -No Sales Employee- | 9 | 3260 |
SQL Server vs SAP HANA
Only identifier quoting differs. COUNT, SUM and the subtraction DocTotal - VatSum behave the same on HANA, and the quoted alias "NetSales" is what ORDER BY refers to.
Common errors and fixes
- A row called '-No Sales Employee-' appears: Invoices saved without a sales employee carry SlpCode -1, which exists in OSLP with that name. Add AND T0.SlpCode <> -1 if you want to hide them, or fix the invoices.
- Commission figures are higher than expected: DocTotal - VatSum still includes freight and rounding. For pure item revenue, sum INV1.LineTotal instead (with the header discount applied, see below), and subtract credit notes (ORIN) for returns.
- Totals don't match the Sales Analysis report (header discount): This query reads DocTotal - VatSum from the document header, which already includes the header discount (OINV.DiscPrcnt), plus freight. If you change it to sum INV1.LineTotal, for example for item revenue, the header discount is not inside LineTotal and the line sum overstates sales. Use SUM(T1.LineTotal * (1 - T0.DiscPrcnt / 100.0)) (HANA: SUM(T1."LineTotal" * (1 - T0."DiscPrcnt" / 100.0))), and subtract credit memos (ORIN/RIN1) with the same factor. See SAP B1 sales total mismatch: header discount fix.
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 dedicated SAP B1 developer for the whole job, fixed price per phase.
Related queries
Table reference: OINV table (A/R Invoice (header)) · OSLP table (Sales Employees)
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 sales by sales employee 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 OINV, OSLP from the standard SAP Business One schema. No user-defined fields are needed.
What should I enter when the selection window opens?
This query uses parameters: [%0] = from date, [%1] = to date. SAP B1 shows a selection window for each one when you run it.
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.
