在此查询中,我试图获取 31、41、125、201 区域的价格相同的值(主要是 r.dpq) ,其中价格应为922,而对于所有其他区域,价格应为 216
该查询确实在 31 , 41 , 125 , 201 地区获取了价格为 216 的产品,但在其他地区没有,我猜错误在这里,但我不知道如何纠正它
rte.TerritoryId not in (31,41,201,125) and rte.PriceCodeId=216 and rte.PartnerTerritoryId is null
这是完整的查询
select r.dpq, r.OwningTerritoryId , r.id from Release r
inner join ReleaseTerritory rt on rt.ReleaseId=r.Id
inner join ReleaseTerritoryPrice rtp on rtp.ReleaseId=r.Id
where exists (
select * from ReleaseTerritoryPrice rtp31, ReleaseTerritoryPrice rtp201,ReleaseTerritoryPrice rtp41,ReleaseTerritoryPrice rtp125,
ReleaseTerritory rt69 , ReleaseTerritoryPrice rte
where
rtp31.ReleaseId=r.Id and rtp201.ReleaseId=r.Id and rtp41.ReleaseId=r.Id and rtp125.ReleaseId=r.Id and rt69.ReleaseId=r.Id and
rte.ReleaseId=r.Id and
rtp31.TerritoryId=31 and rtp201.TerritoryId=201 and rtp41.TerritoryId=41 and rtp125.TerritoryId=125 and
rtp31.PriceCodeId=rtp201.PriceCodeId and rtp201.PriceCodeId=rtp41.PriceCodeId and rtp41.PriceCodeId=rtp125.PriceCodeId and
rt69.TerritoryId=69 and
rtp31.PriceCodeId=922 and
rt69.IsLocked=0 and
rte.TerritoryId not in (31,41,201,125) and rte.PriceCodeId=216 and rte.PartnerTerritoryId is null
) and r.OwningTerritoryId in (201,200)
group by r.dpq , r.OwningTerritoryId , r.Id
order by r.OwningTerritoryId
谢谢你的帮助