Sales Report

Notes • Replace [Start Date] and [End Date] with the desired date range, e.g., '2024-01-01' and '2024-12-31'. • If you want to see additional information, like warehouse or salesperson details, you can join related tables (OWHS for warehouse, OSLP for salesperson). • For more detailed analysis, you can modify the query to group by customer, item, or date.

11/14/20241 min read

SELECT

T0.CardCode AS 'Customer Code',

T0.CardName AS 'Customer Name',

T1.DocNum AS 'Sales Document Number',

T1.DocDate AS 'Document Date',

T1.DocTotal AS 'Total Document Value',

T2.ItemCode AS 'Item Code',

T2.Dscription AS 'Item Description',

T2.Quantity AS 'Quantity Sold',

T2.Price AS 'Unit Price',

(T2.Quantity * T2.Price) AS 'Line Total',

T3.ItmsGrpNam AS 'Item Group'

FROM

OCRD T0

INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode

INNER JOIN INV1 T2 ON T1.DocEntry = T2.DocEntry

LEFT JOIN OITB T3 ON T2.ItemCode = T3.ItmsGrpCod

WHERE

T1.DocDate BETWEEN '[Start Date]' AND '[End Date]' -- Set your date range here

AND T1.Canceled = 'N' -- Exclude canceled invoices

ORDER BY

T0.CardCode, T1.DocDate;