查找父项不是特定元素的子项

| 我想找到一个空的组织元素,它不是parentProblem元素的直接子元素。 像这样
select * from Audit.PatientAudit pa
where pa.BeforeXml.exist(\'//*:organisation[not(../*:parentProblem)]\') = 1
但这似乎行不通,有什么主意吗?     
已邀请:
declare @T table(BeforeXml xml)

insert into @T values
(\'<root>
    <parentProblem>
      <organisation/>
    </parentProblem>
  </root>\'), 
(\'<root>
    <anotherProblem>
      <organisation/>
    </anotherProblem>
  </root>\'),
(\'<root>
    <anotherProblem>
      <organisation ID=\"1\"/>
    </anotherProblem>
  </root>\') 

select *
from @T pa
where pa.BeforeXml.exist(\'//organisation[local-name(..)!=\"parentProblem\" and count(@*)=0]\') = 1
    

要回复问题请先登录注册