I am trying to create a query that will tell me all sales (item qty) to a single customer with multiple ship to addresses. However, I keep getting duplicates in my query.
I started with the below query and everything worked fine.
SELECT T0.[DocNum] AS 'Document Number', T0.[DocStatus] AS 'Document Status', T0.[NumAtCard] AS 'BP Ref No.', T0.[CardName] AS 'Customer/Vendor Name', T0.[ShipToCode] AS 'Ship-to-Code' FROM [dbo].[OINV] T0 WHERE ((T0.[DocStatus]=(N'O')) AND T0.[CardName]=(N'General Motors'))
I know want to include the qty and state but am coming up with duplicates in my result.
SELECT T2.[DocNum] AS 'Document Number', T2.[DocStatus] AS 'Document Status', T2.[CardName] AS 'Customer/Vendor Name', T2.[ShipToCode] AS 'Ship-to Code', T0.[State] AS 'State', T1.[Quantity] AS 'Qty' FROM [dbo].[CRD1] T0 , [dbo].[INV1] T1 INNER JOIN [dbo].[OINV]T2.[DocEntry] =T1.[DocEntry] WHERE (T2.[CardName] = (N'General Motors') AND T2.[DocStatus]=(N'O'))
What am I doing wrong?