我是 SQL Server 的初学者
我在 SAP B1 中的查询是
DECLARE @FROMDATE AS DATETIME
SET @FROMDATE= [%0]
DECLARE @TODATE AS DATETIME
SET @TODATE= [%1]
DECLARE @ACCNUM AS NVARCHAR(100)
SET @ACCNUM= [%2]
获取账户每笔交易的账户名称、编号
SELECT
T4.[ACCOUNT] AS 'A/C NUM',
T4.[ACCTNAME] AS 'A/C NAME',
T4.[TransId] AS 'KEY',
SUM(VEL_DB) AS 'VEL DB',
SUM(VEL_CR) AS 'VEL CR',
SUM(DEF_DB) AS 'DEF_DB',
SUM(DEF_CR) AS 'DEF CR',
T4.[LINEMEMO],
T1.[U_Naaration]
FROM OJDT T1
根据 ocrcode2 计算账户中的每笔交易的贷方和借方
INNER JOIN
(
SELECT T2.[TRANSID],T2.[ACCOUNT],T3.[ACCTNAME],T2.[LINEMEMO],
case
when T2.[OcrCode2]='VEL'
THEN
(T2.[Debit])
ELSE
NULL
END as VEL_DB,
case
when T2.[OcrCode2]='VEL'
THEN
(T2.[CREDIT])
ELSE
NULL
END as VEL_CR,
case
when T2.[OcrCode2]='' OR T2.[OCRCODE2] IS NULL
THEN
(T2.[Debit])
ELSE
NULL
END as DEF_DB,
case
when T2.[OcrCode2]='' OR T2.[OCRCODE2]IS NULL
THEN
(T2.[CREDIT])
ELSE
NULL
END as DEF_CR
FROM JDT1 T2
INNER JOIN OACT T3 ON T3.[ACCTCODE]=T2.[ACCOUNT]
where T2.[DUEDATE]>=@FROMDATE AND T2.[DUEDATE]<=@TODATE )
T4 ON T4.TRANSID = T1.TRANSID AND T4.[ACCOUNT]=@ACCNUM
GROUP BY T4.[TransId] ,T1.[U_Naaration],T4.[ACCTNAME],T4.[ACCOUNT],T4.[LINEMEMO]
FOR BROWSE
我收到错误
必须选择要从中选择的表