forcedotcom/sf-skills / plugins/builder/salesforce-development/skills/platform-soql-query
platform-soql-query
VerifiedUse when the user needs SOQL/SOSL authoring or optimization: natural-language-to-query generation, relationship queries, aggregates, query-plan/selectivity analysis, and performance or safety improvements. TRIGGER when the user writes, optimizes, or debugs SOQL/SOSL, touches .soql files, or asks about relationship queries, aggregates, or query performance. DO NOT TRIGGER for bulk data operations (use platform-data-manage), Apex DML logic (use platform-apex-generate), or report/dashboard queries.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 1.7 KB |
| SKILL.md | skill md | 6.3 KB |
| assets/aggregate-queries.soql | other | 9.4 KB |
| assets/basic-queries.soql | other | 7.4 KB |
| assets/bulkified-query-pattern.cls | other | 10.7 KB |
| assets/optimization-patterns.soql | other | 10.9 KB |
| assets/relationship-queries.soql | other | 7.5 KB |
| assets/selector-class.cls | other | 8.4 KB |
| references/anti-patterns.md | markdown | 8.7 KB |
| references/cli-commands.md | markdown | 7.2 KB |
| references/field-coverage-rules.md | markdown | 14.4 KB |
| references/query-optimization.md | markdown | 3.2 KB |
| references/selector-patterns.md | markdown | 13.7 KB |
| references/soql-reference.md | markdown | 6.4 KB |
| references/soql-syntax-reference.md | markdown | 4.5 KB |
| scripts/post-tool-validate.py | script | 11.9 KB |
assets/basic-queries.soql
View on GitHub/**
* BASIC SOQL QUERY PATTERNS
*
* This file contains common SOQL patterns for everyday queries.
* Each pattern includes the query and usage notes.
*/
// ═══════════════════════════════════════════════════════════════════════════
// SIMPLE SELECT QUERIES
// ═══════════════════════════════════════════════════════════════════════════
-- Get accounts with specific fields
SELECT Id, Name, Industry, AnnualRevenue, Phone
FROM Account
LIMIT 100
-- Get contacts with email
SELECT Id, FirstName, LastName, Email, Phone
FROM Contact
WHERE Email != null
LIMIT 100
-- Get opportunities by stage
SELECT Id, Name, Amount, StageName, CloseDate
FROM Opportunity
WHERE StageName = 'Prospecting'
ORDER BY Amount DESC
// ═══════════════════════════════════════════════════════════════════════════
// DATE FILTERING
// ═══════════════════════════════════════════════════════════════════════════
-- Records created today
SELECT Id, Name FROM Account
WHERE CreatedDate = TODAY
-- Records created this week
SELECT Id, Name FROM Lead
WHERE CreatedDate = THIS_WEEK
-- Records created in last 30 days
SELECT Id, Name, CreatedDate FROM Contact
WHERE CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
-- Records modified this month
SELECT Id, Name, LastModifiedDate FROM Account
WHERE LastModifiedDate = THIS_MONTH
-- Opportunities closing this quarter
SELECT Id, Name, Amount, CloseDate
FROM Opportunity
WHERE CloseDate = THIS_QUARTER
AND IsClosed = false
-- Records created in specific date range
SELECT Id, Name, CreatedDate FROM Account
WHERE CreatedDate >= 2024-01-01T00:00:00Z
AND CreatedDate < 2024-04-01T00:00:00Z
// ═══════════════════════════════════════════════════════════════════════════
// TEXT FILTERING
// ═══════════════════════════════════════════════════════════════════════════
-- Exact match
SELECT Id, Name FROM Account
WHERE Name = 'Acme Corporation'
-- Case-insensitive exact match (default behavior)
SELECT Id, Name FROM Account
WHERE Name = 'acme corporation'
-- Starts with pattern
SELECT Id, Name FROM Account
WHERE Name LIKE 'Acme%'
-- Contains pattern
SELECT Id, Name FROM Account
WHERE Name LIKE '%Corp%'
-- Ends with pattern (NOT indexed - use sparingly)
SELECT Id, Name FROM Account
WHERE Name LIKE '%Inc.'
-- Multiple values
SELECT Id, Name, Industry FROM Account
WHERE Industry IN ('Technology', 'Finance', 'Healthcare')
-- Exclude values
SELECT Id, Name, Industry FROM Account
WHERE Industry NOT IN ('Other', 'Unknown')
// ═══════════════════════════════════════════════════════════════════════════
// NUMERIC FILTERING
// ═══════════════════════════════════════════════════════════════════════════
-- Greater than
SELECT Id, Name, AnnualRevenue FROM Account
WHERE AnnualRevenue > 1000000
-- Range
SELECT Id, Name, Amount FROM Opportunity
WHERE Amount >= 10000 AND Amount <= 100000
-- Not equal
SELECT Id, Name, Amount FROM Opportunity
WHERE Amount != 0
// ═══════════════════════════════════════════════════════════════════════════
// NULL HANDLING
// ═══════════════════════════════════════════════════════════════════════════
-- Find records with null value
SELECT Id, Name FROM Contact
WHERE Email = null
-- Find records with non-null value
SELECT Id, Name, Email FROM Contact
WHERE Email != null
-- Find accounts without opportunities (using NOT IN)
SELECT Id, Name FROM Account
WHERE Id NOT IN (SELECT AccountId FROM Opportunity)
// ═══════════════════════════════════════════════════════════════════════════
// SORTING
// ═══════════════════════════════════════════════════════════════════════════
-- Sort ascending (default)
SELECT Id, Name FROM Account
ORDER BY Name ASC
-- Sort descending
SELECT Id, Name, AnnualRevenue FROM Account
ORDER BY AnnualRevenue DESC
-- Multiple sort fields
SELECT Id, Name, Industry, AnnualRevenue FROM Account
ORDER BY Industry ASC, AnnualRevenue DESC
-- Nulls last
SELECT Id, Name, AnnualRevenue FROM Account
ORDER BY AnnualRevenue DESC NULLS LAST
// ═══════════════════════════════════════════════════════════════════════════
// PAGINATION
// ═══════════════════════════════════════════════════════════════════════════
-- First page (records 1-100)
SELECT Id, Name FROM Account
ORDER BY Name
LIMIT 100
-- Second page (records 101-200)
SELECT Id, Name FROM Account
ORDER BY Name
LIMIT 100
OFFSET 100
-- Note: OFFSET max is 2000. For larger datasets, use query locator in Apex.
// ═══════════════════════════════════════════════════════════════════════════
// COMBINED PATTERNS
// ═══════════════════════════════════════════════════════════════════════════
-- Active technology accounts with high revenue created this year
SELECT Id, Name, Industry, AnnualRevenue, CreatedDate
FROM Account
WHERE Industry = 'Technology'
AND AnnualRevenue > 500000
AND IsActive__c = true
AND CreatedDate = THIS_YEAR
ORDER BY AnnualRevenue DESC
LIMIT 50
-- Contacts with Gmail addresses at accounts in California
SELECT Id, FirstName, LastName, Email, Account.Name
FROM Contact
WHERE Email LIKE '%@gmail.com'
AND Account.BillingState = 'CA'
ORDER BY LastName
-- Open cases older than 7 days
SELECT Id, CaseNumber, Subject, Status, CreatedDate, Owner.Name
FROM Case
WHERE IsClosed = false
AND CreatedDate < LAST_N_DAYS:7
ORDER BY CreatedDate ASC
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |