What is Aggregate Query and Polymorphic Query in Salesforce

Aggregate Query:-

It is use to find the aggregate result for a field. Below are few methods that are supported in Aggregate Query.

  1. Count
  2. Sum
  3. Max
  4. Min
  5. AVG

Select Count(Id), AccountId From Contact Group By AccountId.

For Example:-
  • Select Count(Id), Industry From Account Group By Industry
  • Select SUM(Amount), AccountId, Account.Name From Opportunity Group By AccountId, Account.Name.
  • Select Max(closeDate), Account.Name From Opportunity Group By Account.Name
  • Aggregate query do not return after 2000 records
  • While using Grop by Field in Select Statement either should be Group By OR Aggregated.
  • To Find out the duplicate records based on a particular field. For example , external Id.
  • Select AccountId From Contact Group By AccountId Having Count(Id) > 2
  • Select Email, Count(Id) From Contact Group By Email Having Count(Email) > 1

Polymorphic Query:-

A Polymorphic relationship is one where the current object can be one of several object types depending on a related Events.

For Example:-
  • Select Id, Subject, What.Type, Who.Type From Account Where What.Type='Account'
  • Select Id, Subject, What.Type, Who.Type From Task Where What.Type='Account'


To know more live demo source code in Salesforce lightning, Trigger, Visualforce & LWC, Use this link..



What is Aggregate Query and Polymorphic Query in Salesforce What is Aggregate Query and Polymorphic Query in Salesforce Reviewed by Admin on 3:50 AM Rating: 5

3 comments:

  1. your post is amazing.
    Great Thanks for sharing awesome info. It was very well authored and easy to understand.
    I have a information about fake ID card. Idsbuddy is 𝐛𝐞𝐬𝐭 𝐟𝐚𝐤𝐞 𝐢𝐝 𝐦𝐚𝐤𝐞𝐫 𝐰𝐞𝐛𝐬𝐢𝐭𝐞𝐬. You can learn more information about fake id card from this website.
    you can check best fake id websites

    ReplyDelete
  2. your post is amazing.
    Great Thanks for sharing awesome info. It was very well authored and easy to understand...
    Twitter accounts for sale
    Google voice numbers for sale
    Facebook pva accounts

    ReplyDelete

header banner -- www.w3web.net



Powered by Blogger.