Salesforce SOQL & SOSL Interview Question's
Questions And Answers
Company Asked: Salesforce Experience : 3+ years
1) write a SOQL Query to fetch top 2nd highest marks in student object(table) and English subject(field).
Ans: Student is table.
English is field.
Query: select id, Name, English __c from Student__c order by English __c DESC limit 1 offset 1
Company Asked: Salesforce for TSE Position Experience: 2+ years.
2) write a SOQL Query to parent to child and child to parent.
Ans:
Parent to child
Query: Select name, (select name FROM Contacts) from Account
Child to parent
Query: Select Contact.Name, Contact.Account.Name from Contact
Company Asked: Salesforce for TSE Position Experience: 2+ years.
3)Can you please explain me the difference between SOQL & SOSL.
Ans:
SOQL:
It is stands for Salesforce object Quary language.
It is used to fetch the records from object and related objects.
It can be used in apex classes and apex triggers.
SOSL:
It is stands for salesforce object search language.
It is used to fetch the records from multiple objects and only date ,text ,phone fields.
It is used in apex classes.
Company Asked: Salesforce for TSE Position, TCS Experience: 2+ years.
4)What Is Dynamic SOQL ? Give an example.
Ans:
It Refers to creation of SOQL string at run time using apex code. It gives to chance to create more flexible application in our project.
Example :
We can create SOQL string based on the input of the End user.
Company Asked: Salesforce for TSE Position Experience: 3+ years.
5)Write a SOQL Quary to find accounts with associated contacts that do not have any email IDs associated.
Ans)
SELECT Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Email = NULL)
Feel free to post any comments regarding mistakes, corrections, ideas, and suggestions related to the article.
Thank you for reading the article.
Jayanth A
Comments
Post a Comment