These are SQL questions of the kind Salesforce actually asks — the patterns reported from Salesforce's SQL screens and data/SDE interview rounds. My advice: treat this page as a mock test. Attempt every question on paper first, then reveal. If any answer surprises you, the lesson it comes from is linked right below — go read it, then come back.
Salesforce SQL concept questions
What is a FOREIGN KEY constraint, and what does it enforce?
Asked in


Salesforce SQL query questions
Given customers(email) and newsletter_subscribers(email), write a query using UNION to produce a single deduplicated list of every email address that appears in either table.
Asked in


customers3 rows
| a@x.com |
| b@x.com |
| c@x.com |
newsletter_subscribers2 rows
| b@x.com |
| d@x.com |
Given engineers(emp_id), managers(emp_id), and core_team(emp_id), write a query to return employee IDs that are on the core team AND are either an engineer or a manager -- i.e., (engineers UNION managers) INTERSECT core_team. Explain why writing this without parentheses around the UNION would silently produce a different, incorrect result.
Asked in


engineers3 rows
| emp_id |
|---|
| 1 |
| 2 |
| 3 |
managers2 rows
| emp_id |
|---|
| 4 |
| 5 |
core_team3 rows
| emp_id |
|---|
| 2 |
| 4 |
| 6 |
How to use this page: Salesforce rarely asks a question you've never seen — they ask standard patterns with a twist. Master the pattern in the SQL course lessons, and the twist stops mattering.
Keep practising: SQL Basics, Joins, GROUP BY & HAVING and Subqueries cover what most Salesforce SQL rounds test.

