具有自联接 + 关系的 Salesforce SOQL 查询(ContentDocument/ContentVersion)

Pat*_*ick 2 salesforce force.com soql

我正在尝试编写 SOQL 查询来检索一些 Salesforce Content 记录,但在确定下一步时遇到了一些困难。如果该文档的任何版本的自定义字段具有值(不为空),我想排除该文档的所有版本。这是我正在尝试做的事情的简化版本:

Select  Id, Title
From    ContentVersion
Where   ContentDocumentId Not In
        (
           Select ContentDocumentId,
           From   ContentVersion
           Where  Custom_Field__c != null
        )
Run Code Online (Sandbox Code Playgroud)

所以我知道你不能编写一个子查询来定位与其外部查询相同的对象,所以显然我上面指定的内容是行不通的。关于什么会起作用有什么建议吗?

谢谢。