cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

query

dvix
Discoverer
0 Likes
120
  • SAP Managed Tags

Hi everyone, thanks for all the help you are giving, no doubt you guys are amazing.
I need your help please
I want to generate a query that shows all the revenues, all the return invoices, the salespeople and the customer group by name between certain dates
This is the query I wrote:

SELECT
T0.[DocNum],
T0.[DocDate],
T0.[CardCode],
T0.[CardName],
T0.[DocTotal],
T2.[GroupName],
CASE
WHEN T0.[DocType] = 'I' THEN 'Invoice'
WHEN T0.[DocType] = 'R' THEN 'Refund'
ELSE 'Other'
END AS DocumentType
FROM
(
SELECT *,'I' as DocType FROM OINV
UNION ALL
SELECT *,'R' as DocType FROM ORIN
) AS T0
INNER JOIN OCRD T2 ON T0.[CardCode] = T2.[CardCode]
INNER JOIN OCRG T3 ON T2.[GroupCode] = T3.[GroupCode]
WHERE
T0.[DocDate] BETWEEN [%0] AND [%1]
AND T2.[GroupCode] = [%2]

And this is the error i get: 

1). [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Must specify table to select from. 2). [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement 'התראות שנתקבלו' (OAIB) (s) could not be prepared.

please help me solve it

Accepted Solutions (0)

Answers (0)