Skip to Content
0
Aug 22, 2017 at 12:31 PM

Need help with query - Sales Analysis with GM

115 Views

I am trying to do a slaes analysis report. The info I am trying to end up with is

Customer (Code and Name)

Sales Order number

Sales Order Total

GM for Each Sales Order

I tried doing the following which gives me all of the line detail:

SELECT

T1.[DocNum] AS 'Document Number',

T1.[CardCode] AS 'Customer/Vendor Code',

T1.[CardName] AS 'Customer/Vendor Name',

T1.[DocDate] AS 'Posting Date',

T1.[TaxDate] AS 'Document Date',

T0.[ItemCode] AS 'Item No.',

T0.[Dscription] AS 'Item/Service Description',

T0.[Quantity] AS 'Quantity',

T0.[GrossBuyPr] AS 'Gross Buy Price',

T0.[Price] AS 'Unit Price'

FROM [dbo].[RDR1] T0 INNER JOIN [dbo].[ORDR] T1 ON T1.[DocEntry] = T0.[DocEntry]

Then I would export to Excel and calculate the GM for each line. The problem is when I have to total each Sales Order and then group by Customer. I would appreciate any help possible.

Thank you,

Keith H