Preface: this post is part of the SOQL: A Beginner’s Guide series.
Chapter 2 Questions:
1. Why do 95% of triggers use SOQL?
2. What are the two words that appear in every SOQL statement?
3. Name at least three places you can write SOQL.
4. Which of these two statements will break and why?
SELECT Id FROM User WHERE IsActive = true
SELECT Id FROM User WHERE IsActive = ‘false’
5. Finish this statement which wants to query all Leads with an email address:
SELECT Id FROM Lead WHERE Email
6. Finish this statement, which wants to query all Accounts with names that start with an ‘A’
SELECT Id FROM Account WHERE Name LIKE
7. Write a query that gets all Opportunities with a Close Date in the future.
8. Which direction are these relationships? Upwards or downwards.
a. Contacts to Accounts
b. Accounts to Tasks
c. Opportunity Line Items to Opportunities
d. Accounts to Quote Line Items
e. Campaign Members to Accounts
f. Opportunity History to Accounts
9. When do you use __r instead of __c?
10. Write a query that gets a Contact’s Account owner’s username and their best friend as well as all related Tasks that were created in the last 90 days or have both a comment that contains the words ‘nutella’ and ‘krispy kreme’ and the Task creator’s title is populated. Oh yes – all the contacts have to weigh more than 120 pounds and have a best friend whose owner’s name ends in a ‘d’. No more than 100 records please… whew!