2023 Dec 28 8:39 AM
Dear SAP Community, I'd like to ask for help with a query. I want to run a query that returns open Invoices shipped from a particular warehouse, with specific payment terms. I'd like the query to return one row per invoice instead of all invoice rows. Am trying to use the GROUP BY statement, but am failing. How can I correct the query?
SELECT T1.[DocEntry] AS 'Doc Entry', T1.[DocNum] AS 'Invoice No.', T0.[PymntGroup] AS 'Payment Terms', T2.[WhsCode] AS 'Warehouse', T1.[DocStatus] AS 'Doc Status', T1.[DocDate] AS 'Posting Date', T1.[CardCode] AS 'BP Code', T1.[CardName] AS 'BP Name'
FROM OCTG T0 INNER JOIN OINV T1 ON T1.[GroupNum] = T0.[GroupNum] INNER JOIN INV1 T2 ON T2.[DocEntry] = T1.[DocEntry]
GROUP BY T1.[DocNum]
WHERE (T2.[WhsCode] = (N'9000' ) AND T1.[DocStatus] = ('O' ) ) AND (T0.[PymntGroup] = (N'visa/Master Card' ) OR T0.[PymntGroup] = (N'American Express' ) )
Thank you,