0
以下查询返回需要的内容,但我需要修改它,以便我可以从 只选择DocID
数大于3的文档中的记录以及where子句中的内容。如果试图这样做,我总是得到错误:select with multiple where和count
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
我将如何编写查询,以满足DocID
是大于3的计数? DocID
是文档表的PK。
use newCityCollection
select a.CaseNumberKey, a.SearchUserID, c.DocType, c.RelatedDocID
from documents c
JOIN newCityCollection.dbo.PropertyInformation a ON C.CaseNumberKey = A.CaseNumberKey
where c.DocType = 'Assignment' and c.RelatedDocID is null and a.ClientKey = 3 and (count(c.docID) > 3)
添加您的表的模式,以便我们能够理解其中的DocID从何而来。你还使用哪个rdbms?它是SQLServer吗? –
你可以用'COUNT'函数向我们显示你的查询吗? – Marusyk
你是什么意思的架构?它是dbo,是自动增量整数。 – korrowan