gpt4 book ai didi

sql - 关键字 'SELECT' 附近的语法不正确。 ')' 附近的语法不正确

转载 作者:行者123 更新时间:2023-12-04 23:52:03 27 4
gpt4 key购买 nike

我用的是vb.net中的sql代码

SELECT [Table1 Query].[amel_code], [Table1 Query].[kala_code], Sum([Table1 Query].
[SumOfqty]) AS SumOfSumOfqty FROM(
SELECT Table1.amel_code,
Table1.amani_code,
Table1.kala_code,
Sum(Table1.qty) AS SumOfqty
FROM Table1
GROUP BY Table1.amel_code,
Table1.amani_code,
Table1.kala_code HAVING (((Table1.amel_code)=[?]) AND ((Table1.amani_code)<[?]));
)
GROUP BY [Table1 Query].[amel_code], [Table1 Query].[kala_code];

此代码运行正常,但 sql web.工作表出现以下错误:

Incorrect syntax near the keyword 'SELECT'. Incorrect syntax near ')'.

请帮助我。

最佳答案

您需要删除嵌套查询末尾的分号,并为其添加别名:

SELECT [Table1 Query].[amel_code], [Table1 Query].[kala_code], Sum([Table1 Query].[SumOfqty]) AS SumOfSumOfqty
FROM (
SELECT Table1.amel_code,
Table1.amani_code,
Table1.kala_code,
Sum(Table1.qty) AS SumOfqty
FROM Table1
GROUP BY Table1.amel_code,
Table1.amani_code,
Table1.kala_code
HAVING (((Table1.amel_code)=[?])
AND ((Table1.amani_code)<[?])) -- ; <<== Remove this semicolon
) [Table1 Query] -- <<== Add this alias
GROUP BY [Table1 Query].[amel_code], [Table1 Query].[kala_code];

Demo on SQLFiddle.

关于sql - 关键字 'SELECT' 附近的语法不正确。 ')' 附近的语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20298201/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com