我正在尝试“加入”来计算团队成员根据我们收到的钱获得的报酬。
在我的机会上,我有两个相关的名单,包括Master / Child 1)团队成员 - 与他们应该接受的机会和佣金的人一起。我们收到报酬后会得到报酬。 2)付款 - 我们收到的付款。
我需要运行一个联接查询,以便将我们在一段时间内收到的每笔付款与同一机会的相关团队成员相匹配。
此查询似乎有效
SELECT Amount__c, Method__c, Opportunity__c ,OwnerId, User__c, RoleCode__c, Name FROM Sales_Team__c where Opportunity__c IN (SELECT Opportunity__c FROM Payment__c) LIMIT 10
但是,我需要在Payment对象上看到Payment_Amount,所以我将它添加到第二个'select'
SELECT Amount__c, Method__c, Opportunity__c ,OwnerId, User__c, RoleCode__c, Name FROM Sales_Team__c where Opportunity__c IN (SELECT Opportunity__c FROM Payment__c) LIMIT 10
现在我收到此错误
There has been an error in the SOQL query: MALFORMED_QUERY: Opportunity__c IN (SELECT Opportunity__c, Payment_Amount__c FROM Payment__c) ^ ERROR at Row:1:Column:148 unexpected token: ,
如何从Payments表中提取其他列?
任何和所有帮助都会非常感激。 伊恩
答案 0 :(得分:0)
当你在where子句中寻找Opportunity__c时,为什么要在查询中添加Payment_Amount__c。
SELECT Opportunity__c, Payment_Amount__c FROM Payment__c
除非你的查询中有拼写错误,否则这应该可以正常工作
SELECT Amount__c, Method__c, Opportunity__c ,OwnerId, User__c, RoleCode__c, Name FROM Sales_Team__c where Opportunity__c IN (SELECT Opportunity__c FROM Payment__c) LIMIT 10
答案 1 :(得分:0)
我认为你的意思是
SELECT Amount__c, Method__c, Opportunity__c ,OwnerId, User__c, RoleCode__c, Name,(SELECT Opportunity__c, Payment_Amount__c FROM Payment__c) FROM Sales_Team__c where Opportunity__c IN (SELECT Opportunity__c FROM Payment__c) LIMIT 10