我需要帮助,我需要将SQL语法转换为MS Access语法,我不知道如何。
INSERT INTO SampleData2
SELECT
Object_Account, Descriptions, GL_Date, Document_Type,
Document_Number, Company, Subledger, Subledger_Type, ' ',
SUM(Actual_Amount * -1) AS TotalAmount,
(JE_Explantion) AS Explanation
FROM
SampleData
WHERE
CAST(Object_Account AS VARCHAR(20)) + Subledger + JE_Explantion
IN (SELECT CAST(Object_Account AS VARCHAR(20)) + Subledger + JE_Explantion
FROM SampleData
GROUP BY Object_Account, Subledger, JE_Explantion
HAVING COUNT(Object_Account) > 1)
GROUP BY
Object_Account, Descriptions, GL_Date, Document_Type,
Document_Number, Company, Subledger, Subledger_Type, Remarks,
JE_Explantion
答案 0 :(得分:1)
MS Access使用&用于字符串连接,不支持cast()
。你可以试试:
INSERT INTO SampleData2
SELECT Object_Account, Descriptions, GL_Date, Document_Type, Document_Number,
Company, Subledger, Subledger_Type, ' ', Sum(Actual_Amount * -1) AS TotalAmount, (JE_Explantion) As Explanation
FROM SampleData as sd
WHERE EXISTS (SELECT 1
FROM SampleData as sd2
WHERE sd2.Object_Account = sd.Object_Account AND
sd2.Subledger = sd.Subledger AND
sd2.JE_Explantion = sd.JE_Explantion
GROUP BY Object_Account, Subledger, JE_Explantion
HAVING COUNT(Object_Account) > 1
)
GROUP BY Object_Account, Descriptions, GL_Date, Document_Type, Document_Number,
Company, Subledger, Subledger_Type, Remarks, JE_Explantion;