I'm new to SOQL queries. I am trying to write a query that will calculate the total number of UNIQUE products a user has applied to their history of opportunities. The goal being to assess their product diversity usage.
Example: A salesperson has 5 opportunities
- Oppty 1 - Product A
- Oppty 2 - Products B, C
- Oppty 3 - Products A, C
- Oppty 4 - Products A
- Oppty 5 - Product C
Their total product count would be A(3), B(1), C(3). Their UNIQUE products are A,B,C = 3 Products
What would be the best way to calculate this across 50,000 opportunity records considering any governor limits?
Also, can a query like this be written as a SOQL query that can be run in a tool like dataloader or workbench?