SOQL Query: Cases by Owner in Salesforce
Query cases by owner in SOQL - filter on OwnerId, dot-walk to Owner.Name, and count records per owner before a reassignment.
Updated 2026-09-09
Ownership queries answer the two questions that precede every territory change: who owns what, and how much will move.
Support orgs generate cases faster than any other object, which makes LIMIT and selective filters mandatory rather than optional.
Filter by owner name
Owner.Name dot-walks to the related User record. It reads well, but filtering on OwnerId is faster and immune to name changes.
SELECT Id, CaseNumber, Subject, Owner.Name
FROM Case
WHERE Owner.Name = 'Jane Smith'
ORDER BY CreatedDate DESCFilter by user ID
SELECT Id, CaseNumber, Subject
FROM Case
WHERE OwnerId = '005XXXXXXXXXXXXXXX'Count per owner before a reassignment
Run this before a mass owner change so you know the blast radius. Pair it with a query for inactive owners - orphaned cases are a standard audit finding.
SELECT OwnerId, COUNT(Id) total
FROM Case
GROUP BY OwnerId
ORDER BY COUNT(Id) DESCRecords owned by inactive users
SELECT Id, CaseNumber, Subject, Owner.Name
FROM Case
WHERE Owner.IsActive = falseCommon mistakes to avoid
- Use the API name
Case, not the UI label - the two differ on several standard objects. - Wrap literal text values in single quotes; date literals such as
LAST_N_DAYS:30must stay unquoted. - Run the query in a sandbox first if it feeds a bulk update - a
WHEREclause that is one character off can select the whole table.
Run it faster with TurboKit
Reassignment work means exporting the matching IDs and importing them back with a new OwnerId.
TurboKit's AI SOQL builder lets you describe the result you want in plain English, returns the query, and exports the rows to CSV or Excel in the same panel - without leaving the Salesforce tab you are already on.
Frequently asked questions
- Should I filter on OwnerId or Owner.Name?
OwnerIdfor anything scheduled or automated - it is indexed and stable.Owner.Nameis fine for ad-hoc investigation, but it breaks when someone changes their name.- Can queues own cases?
- For objects that support queues,
OwnerIdcan hold a Group ID instead of a User ID. Filtering onOwner.Typedistinguishes the two. - Why do I see fewer records than my colleague?
- SOQL run through the UI or API respects sharing rules for that user. Admins with View All Data see the full set; everyone else sees their share.
More from the SOQL Library
- SOQL GROUP BY: Cases by StatusAggregate SOQL that breaks cases down by Status, with COUNT, SUM, and the AggregateResult alias rules.
- SOQL Query for Cases Created in the Last 30 DaysSOQL for cases created in the last 30 days, plus the date literals (TODAY, THIS_MONTH, LAST_N_DAYS) that replace hard-coded dates.
- SOQL Query for the Latest Cases (ORDER BY and LIMIT)Return the most recent cases with ORDER BY and LIMIT, plus OFFSET paging and the null-ordering options most admins never touch.
- SOQL Query to Count Cases in SalesforceCopy-paste SOQL to count cases in Salesforce, with variants for filtered counts, COUNT(Id) vs COUNT(), and grouped totals.
- SOQL Query: Accounts by Owner in SalesforceQuery accounts by owner in SOQL - filter on OwnerId, dot-walk to Owner.Name, and count records per owner before a reassignment.
- SOQL Query: Campaigns by Owner in SalesforceQuery campaigns by owner in SOQL - filter on OwnerId, dot-walk to Owner.Name, and count records per owner before a reassignment.
Related reading
- Admin How-ToHow to Write Salesforce Queries Without Knowing SOQL (AI SOQL)Describe the records you want in plain English and get a runnable SOQL query back - how AI SOQL builders work, what to check before you run the result, and where they still fall short.
- GlossaryWhat Is an AI SOQL Builder in Salesforce?An AI SOQL builder turns a plain-English description of the records you want into a runnable SOQL query, using the schema of the org you are working in so the