SOQL Result when Multiple Records having the same Name

Interview Question: In my Salesforce org, I have Contact records where some share the exact same name. If I run a query filtering by name, which record will be returned first?

Many Contacts with same Name
Select Id,Name, CreatedDate,OtherPhone From Contact Where Name= 'Billi Jonh'

What will be result of above SOQL?

The order of this query results is not guaranteed. It could vary depending on internal indexing, query optimization.

By default, Salesforce SOQL does not guarantee any specific order of records unless you explicitly use an ORDER BY clause.

See in action

Leave a Reply