Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to use SOQL Count()?

Asked by Dia Shrinidhi May 12, 2023 1.1K views 1 answer
Share

About this question

I have a custom object. This custom object has a field Cabin_Type__c, which has values of Twin and Luxury. There is another field Deck_Type__c which is just the number of the deck such as 1,2,3,etc.

So here are what a few of my custom objects might look like

obj1={Cabin_Type__c=Twin, Deck_Type__c=1} obj2={Cabin_Type__c=Twin, Deck_Type__c=1} obj3={Cabin_Type__c=Twin, Deck_Type__c=1} obj4={Cabin_Type__c=Luxury, Deck_Type__c=1} obj5={Cabin_Type__c=Luxury, Deck_Type__c=1} obj6={Cabin_Type__c=Twin, Deck_Type__c=2} obj7={Cabin_Type__c=Twin, Deck_Type__c=2}

From the above data, I would like to be able to extract through SOQL the count of cabin types by deck. So from the 7 objects above, I would get

Deck 1 Twin (3)
Deck 1 Luxury (2)
Deck 2 Twin (2)

Is there something in SOQL similar to count() in SQL that I could use for this?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.