Sql server 2012 从SQL Server中具有等于条件的表中选择
请查看我的数据快照 我希望实现以下目标:Sql server 2012 从SQL Server中具有等于条件的表中选择,sql-server-2012,Sql Server 2012,请查看我的数据快照 我希望实现以下目标: select record where (`adslocationdescription` = "jawa timur" and `type` = 1) or (`adslocationdescription` != 'jawa timur and `type` = 2) 但是,如果adscampaincode有一个等于(adslocationdesc=“jawa timur”和类型=2)的记录,则不应选择任何数据。与以下内容类
select record
where (`adslocationdescription` = "jawa timur" and `type` = 1) or
(`adslocationdescription` != 'jawa timur and `type` = 2)
但是,如果
adscampaincode
有一个等于(adslocationdesc
=“jawa timur”和类型
=2)的记录,则不应选择任何数据。与以下内容类似的内容(未测试代码):
到目前为止你试过什么?你在哪里挣扎?
select * from myTable
where (AdsLocationDescription = 'Jawa Timur' AND (Type = 1 OR Type = 2))
AND AdsCampaignCode NOT IN
-- this subquery gets AdsCampaignCodes that
-- DO have LocationDescription of Jawa Timur
(select distinct AdsCampaignCode
from myTable
where AdsLocationDescription = 'Jawa Timur')