经过多次试验和错误运行后,我似乎无法修复语法错误。我试图连接一些数据,并一直在使用Allen Browne(你可以找到ConcatRelated的代码),我从另一个stackoverflow问题得到了SQL,但他们有不同的数据类型。
以下是我尝试运行的查询的SQL,这令人惊讶地产生了正确的结果以及此错误,这使得查询无用。 (StmntNd是文本字段,Assmt_Group是数字字段)
SELECT sub.[StmntNd], sub.[Assmt_Group], sub.[StmntDes], ConcatRelated("Num_Code", "tbl_Property", "[StmntNd] = '" & sub.[StmntNd] & "' AND [Assmt_Group] = " & sub.[Assmt_Group], "num_Code") AS concat_num_code
FROM (SELECT q.[StmntNd], q.[Assmt_Group], q.[StmntDes] FROM tbl_Property AS q GROUP BY q.[StmntNd], q.[Assmt_Group], q.[StmntDes]) AS sub
ORDER BY sub.StmntNd, sub.Assmt_Group;
非常感谢您的帮助。无论我使用什么引号和撇号组合,我似乎都会遇到错误。
答案 0 :(得分:1)
try this
SELECT sub.[StmntNd], sub.[Assmt_Group], sub.[StmntDes], ConcatRelated("Num_Code", "tbl_Property", "[StmntNd] = '" & sub.[StmntNd] & "' AND [Assmt_Group] = " & sub.[Assmt_Group], "num_Code") AS concat_num_code
FROM (SELECT q.[StmntNd], q.[Assmt_Group], q.[StmntDes] FROM tbl_Property AS q
GROUP BY q.[StmntNd], q.[Assmt_Group], q.[StmntDes]) AS sub
Where q.[StmntNd] is Not Null
ORDER BY sub.StmntNd, sub.Assmt_Group;
Add where clause to the Column, I assumed column as q.[StmntNd]