gpt4 book ai didi

sql - 如何解决 SQL Server 错误 "An expression of non-boolean type specified in a context where a condition is expected, near ' GROUP'"

转载 作者:行者123 更新时间:2023-12-02 08:20:08 25 4
gpt4 key购买 nike

这是我的查询

INSERT INTO Tbl_DomainWiseStats (subdomainid, tendercount, Type_cat, DisplayText)
SELECT
' + CAST(@domain_id AS VARCHAR(100)) + '
, TenderCount
, ''ByCountry''
,Country
FROM
(SELECT DISTINCT
V.Country,
COUNT(DISTINCT Sr_No) as TenderCount
FROM
dbo.viewgetlivetenders V
WHERE
'+ @Domainquery +'
GROUP BY
V.Country) a
ORDER BY
TenderCount

错误信息:

[SQLSTATE 42000] (Error 4145) An expression of non-boolean type specified in a context where a condition is expected, near 'GROUP'

最佳答案

你需要完成你的 where 子句..

这会导致错误:

select * from test where id

但不是这个:

select * from test where id =1

在您的动态 SQL 中,以下部分导致问题..

WHERE '+  @Domainquery +' 
GROUP BY V.Country

关于sql - 如何解决 SQL Server 错误 "An expression of non-boolean type specified in a context where a condition is expected, near ' GROUP'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37987175/

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