• Worf
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Im relatively new to Database queries, but the situation is for a little while we had an online scripts creating creating duplicate entries for the contact role in each opportunity created. That problem was fixed but now I just need to create a SOQL report of just the duplicates so I can go through and delete one of each.

This is the SOQL Query I try:

 

select ID, ContactID, OpportunityIDCOUNT(OpportunityID)

from OpportunityContactRole 

where Role != NULL

GROUP BY OpportunityID

HAVING COUNT(OpportunityID) > 1

 

This is returning the error:

 

MALFORMED_QUERY:
ContactID, OpportunityID, COUNT(OpportunityID)
^
ERROR at Row:1:Column:40
Grouped field should not be aggregated: OpportunityId

 

Can someone help me with this?

 

  • July 23, 2013
  • Like
  • 0

Im relatively new to Database queries, but the situation is for a little while we had an online scripts creating creating duplicate entries for the contact role in each opportunity created. That problem was fixed but now I just need to create a SOQL report of just the duplicates so I can go through and delete one of each.

This is the SOQL Query I try:

 

select ID, ContactID, OpportunityIDCOUNT(OpportunityID)

from OpportunityContactRole 

where Role != NULL

GROUP BY OpportunityID

HAVING COUNT(OpportunityID) > 1

 

This is returning the error:

 

MALFORMED_QUERY:
ContactID, OpportunityID, COUNT(OpportunityID)
^
ERROR at Row:1:Column:40
Grouped field should not be aggregated: OpportunityId

 

Can someone help me with this?

 

  • July 23, 2013
  • Like
  • 0