7 Ways To Use SOQL
7 Ways To Use SOQL
List<Contact> lstContacts =
[SELECT Id, Name, Phone, BirthDate
FROM Contact]
@ soham-datta
Construct Map:
@ soham-datta
Parent Child Relationship:
List<Account> lstAccounts =
[SELECT Id, Name,
(SELECT Name FROM Contacts)
FROM Account]
@ soham-datta
Child Parent Relationship:
List<Contact> lstContacts =
[SELECT Id, Name, Phone, Sex__c,
Account.Website, Account.Name
FROM Contact]
@ soham-datta
Aggregate Query:
List<AggregateResult> grpResults =
[SELECT Name, AVG(Amount)aver
FROM Opportunity
Group By Name
Having AVG(Amount) > 50000];
Object avgAmount =
grpResults[0].get('aver');
@ soham-datta
Dynamic Query:
List<sObject> lstContacts =
Database.query(string);
@ soham-datta
Count Query:
Integer numOfAccRecords =
[ SELECT COUNT()
FROM Account
WHERE Name LIKE 'a%'];
@ soham-datta
Let's Connect
@ soham-datta
@ soham-datta