您可以使用
HAVING
条款,如果
ID
是你唯一需要的专栏
IN()
在此处查看实时演示
Response waiting questions
Select distinct top 100
'http://stackoverflow.com/questions/'+Cast(p.Id as varchar(20)) as ids
from Posts p
Join posttags pt
on p.Id=pt.PostId
where AcceptedAnswerId is null
and AnswerCount <3
and len(body) <2000
and viewCount<30
and DateDiff(hour, p.creationDate, GETDATE())<200
and ClosedDate is null
GROUP BY 'http://stackoverflow.com/questions/'+Cast(p.Id as varchar(20))
HAVING COUNT(*) = SUM(CASE WHEN tagID IN(21,3,9,820,2,22,1508,46426,96,363) THEN 1 ELSE 0 END)
COUNT(*)
将返回此的记录总数
身份证件
这个
SUM(CASE..)
将返回没有不需要的标记的记录数。如果它们相等,则意味着只存在所需的标记。