Sample Queries for Debugging
This document provides a starting point for exploring and debugging your Salesforce Data Cloud instance. These sample queries are designed to help you understand your data structure, identify issues, and verify data quality.
Most queries are interactive with real sample results from actual Data Cloud instances, making it easy to see what the output should look like and understand the data patterns you can expect.
Getting Started
Prerequisites
Before using these queries, you need to connect to your Salesforce Data Cloud instance. You can use any of the following platforms to run these queries:
- DBeaver (recommended) - Follow the DBeaver Connection Guide to set up the connection using the Data Cloud JDBC Driver
- Data Cloud Query Editor - Good for one-off queries, accessible directly in the Data Cloud interface
- Tableau Custom SQL - For integration with Tableau dashboards (I haven't tested this yet)
Tips for Using These Queries
- Adjust Date Ranges: Modify the date intervals based on your data volume and requirements
- Check Data Availability: Some queries may return empty results if no data exists for that Object in your Data Cloud instance.
- Data Model Object Availability: A Data Model Object must have at least one mapped Data Stream to be queryable. Without any mapped Data Streams, queries will return an error indicating the table does not exist.
- Credit Consumption: These queries use the Data Cloud Query API, which consumes Data Cloud credits
- Standard Customer 360 DMOs: These queries use the standard Customer 360 Data Model Objects (DMOs) that are available in Salesforce Data Cloud. These DMOs provide a unified view of customer data across all your connected data sources. You can identify these DMOs by looking for the
ssot__
prefix in the DMO API Name, similarly the standard fields on these objects have thessot__
prefix, so you can easily distinguish them from custom fields.
Shared DMO API Names: Fields marked with 🔗 Shared are synchronized across all queries on this page for convenience. When you update a shared field in one query, it automatically updates all similar fields. These values are stored locally in your browser and will persist when you reload the page. No values ever reach our server - all data remains on your device.
Frequently Used Queries
This section contains queries for the most common, day-to-day tasks, such as finding specific (unified) individuals and analyzing segment membership.
Find a Person's Data
Use these queries to quickly locate Unified Individual profiles using their contact information (email addresses, phone numbers, etc.) and understand their segment memberships. This is the primary way to find customer profiles in Data Cloud.
Find Unified Individuals by Contact Points
This query answers: How can I find Unified Individual profiles using their contact information? It's the primary way to locate customer profiles using email addresses, phone numbers, or other identifiers. This query retrieves Unified Individual records with comprehensive contact information and identity resolution details.
-- Find Unified Individual records by contact points (email, phone, etc.)
SELECT
ui."ssot__Id__c",
ui."ssot__FirstName__c",
ui."ssot__LastName__c",
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT iil."SourceRecordId__c"), ', ') AS individual_ids,
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT e."ssot__EmailAddress__c"), ', ') AS email_addresses,
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT p."ssot__TelephoneNumber__c"), ', ') AS phone_numbers,
ui."ssot__CreatedDate__c",
ui."ssot__LastModifiedDate__c"
FROM "UnifiedIndividual__dlm" ui
INNER JOIN "IndividualIdentityLink__dlm" iil ON ui."ssot__Id__c" = iil."UnifiedRecordId__c"
INNER JOIN "UnifiedContactPointEmail__dlm" e ON ui."ssot__Id__c" = e."ssot__PartyId__c"
INNER JOIN "UnifiedContactPointPhone__dlm" p ON ui."ssot__Id__c" = p."ssot__PartyId__c"
GROUP BY
ui."ssot__Id__c",
ui."ssot__FirstName__c",
ui."ssot__LastName__c",
ui."ssot__CreatedDate__c",
ui."ssot__LastModifiedDate__c"
ORDER BY ui."ssot__CreatedDate__c" DESC
LIMIT 1000;
Sample Output
unified_individual_id | first_name | last_name | individual_ids | email_addresses | phone_numbers | created_date | last_modified_date |
---|---|---|---|---|---|---|---|
cde3951f696e371e04508618b20da9b4 | Lucas | Nasser | 003Ho000025wcFTIAY | lucas.nasser39@outlook.com | +971562358743 | 2025-07-10T21:36:19+00:00 | 2025-07-10T21:36:19+00:00 |
0f9a46fbb34860cd77a76a883776afe6 | Mia | Nasser | 00QHo000010wWfwMAE | mia.nasser72@hotmail.com | +971560339995 | 2025-07-10T21:36:19+00:00 | 2025-07-10T21:36:19+00:00 |
661bf2ec29522365ec6567b39842311a | Omar | Brown | 00QHo000010wWfyMAE | omar.brown44@yahoo.com | +971556896456 | 2025-07-10T17:36:19+00:00 | 2025-07-10T17:36:19+00:00 |
6b0cabf0ba1fc76be1994f426df1ff68 | Lucas | Jones | 00QHo000010wWfxMAE | lucas.jones66@hotmail.com | +971519139169 | 2025-07-10T17:36:19+00:00 | 2025-07-10T17:36:19+00:00 |
3762af19220aa24988db98a3d89be793 | Olivia | Brown | 00QHo000010wWg0MAE | olivia.brown86@yahoo.com | +971559944183 | 2025-07-10T17:36:19+00:00 | 2025-07-10T17:36:19+00:00 |
Analysis: This query successfully retrieves Unified Individual profiles with comprehensive contact information. The results show:
- Good data quality: All profiles have both email addresses and phone numbers
- Recent data: All records were created on 2025-07-10, indicating recent data ingestion
- Geographic diversity: Phone numbers show UAE format (+971), suggesting international customer base
- Identity resolution working: Each profile has a single Individual ID, indicating 1:1 mapping (no complex matches)
Recommendations:
- Use this query as a template for customer lookup operations
- Consider adding filters for specific date ranges to improve performance
- Monitor for profiles with multiple Individual IDs, which would indicate identity resolution matches
Check Segment Membership
These queries help you list, count, and retrieve members from your marketing segments.
Segment Member Counts by Segment
This query answers: What is the current member count for each published segment?
-- Segments with members (categorized by type)
-- Parameters used:
-- Unified Table: Individual_Unified_INSTANCESPECIFIC__dlm
-- Individual Table: Individual_INSTANCESPECIFIC__dlm
SELECT
CASE
WHEN COUNT(ius."Segment_Id__c") > 0 THEN 'Unified Individual'
WHEN COUNT(ism."Segment_Id__c") > 0 THEN 'Individual'
ELSE 'Unknown'
END AS segment_on,
ms."ssot__Name__c" AS segment_name,
COALESCE(COUNT(ius."Segment_Id__c"), 0) + COALESCE(COUNT(ism."Segment_Id__c"), 0) AS member_count
FROM "ssot__MarketSegment__dlm" ms
LEFT JOIN "Individual_Unified_INSTANCESPECIFIC__dlm" ius
ON ius."Segment_Id__c" = SUBSTRING(ms."ssot__Id__c", 1, 15)
LEFT JOIN "Individual_INSTANCESPECIFIC__dlm" ism
ON ism."Segment_Id__c" = SUBSTRING(ms."ssot__Id__c", 1, 15)
GROUP BY ms."ssot__Name__c"
ORDER BY member_count DESC
Sample Output
segment_on | segment_name | member_count |
---|---|---|
Individual | test individual | 141 |
Unified Individual | test segment membership DMO | 130 |
Unified Individual | Bought Sunglasses Without Prescription | 103 |
Unknown | test | 0 |
Analysis: This query provides a comprehensive overview of segment membership across different types. The results show:
- Active segments: Three segments have members, with "test individual" being the largest (141 members)
- Segment type distribution: Mix of Individual and Unified Individual segments, indicating different identity resolution approaches
- Empty segment: One segment ("test") has 0 members, suggesting it may need review or cleanup
- Business relevance: "Bought Sunglasses Without Prescription" appears to be a meaningful business segment
Recommendations:
- Review the "test" segment with 0 members - consider deleting or repopulating it
- Monitor segment growth trends to identify which segments are most effective
- Consider consolidating similar test segments to reduce complexity
- Validate that segment membership counts align with business expectations
Find Segments for a Specific Contact Point
This query answers: Which segments does a person with a specific email or phone number belong to?
-- Please provide either an email address or phone number to filter by
Sample Output
segment_id | segment_name | segment_type | unified_individual_id | first_name | last_name | email_addresses | phone_numbers |
---|---|---|---|---|---|---|---|
1sgHo000000g1H2IAI | Bought Sunglasses Without Prescription | Unified Individual | a9d0c35593f5ab177fb826d28245e0e4 | Noah | Khan | noah.khan58@yahoo.com | +971574666796 |
1sgHo000000g1HWIAY | High Value Customers | Individual | a9d0c35593f5ab177fb826d28245e0e4 | Noah | Khan | noah.khan58@yahoo.com | +971574666796 |
1sgHo000000g1NUIAY | Has Purchased in the Last 30 Days | Unified Individual | a9d0c35593f5ab177fb826d28245e0e4 | Noah | Khan | noah.khan58@yahoo.com | +971574666796 |
Analysis: This query successfully finds all segments that a specific contact point belongs to. The results show:
- Multiple segment membership: Noah Khan belongs to 3 different segments
- Identity resolution: The same person appears in both Unified Individual and Individual segments
- Contact consistency: Same email and phone across all segment memberships
- International data: UAE phone number (+971) indicates global customer base
Recommendations:
- Use this query to understand customer segment overlap and targeting
- Monitor for customers in too many segments (potential over-targeting)
- Validate that segment membership aligns with business rules
- Consider implementing segment membership limits for better targeting
- Review international customer segment distribution for localization strategies
Get (Unified) Individuals in a Specific Segment
This query answers: Who are the members of a specific segment and what are their contact details?
-- Please provide a segment name to filter by
Sample Output
segment_name | segment_type | id | first_name | last_name | email_addresses | phone_numbers |
---|---|---|---|---|---|---|
Bought Sunglasses Without Prescription | Unified Individual | de82b0e7026702e26f2d72d2e2c25506 | Sean | Silver | ssilver@example.com | +13105550100 |
Bought Sunglasses Without Prescription | Unified Individual | cb9ab89c8c2762f04b40ca4142ee8cf1 | Patricia | Feager | pfeager@example.com | (415) 777-8888 |
Bought Sunglasses Without Prescription | Unified Individual | c7b8237a84c29ed308bfd702f20875e6 | Mike | Welch | mwelch@example.com | (415) 555-2110 |
Bought Sunglasses Without Prescription | Unified Individual | 8f37d2e1a5b9c4f6e8d2a1b9c4f6e8d2 | Sarah | Johnson | sjohnson@example.com | (555) 123-4567 |
Bought Sunglasses Without Prescription | Unified Individual | 6d15b0c9a3b7c2d4e6d0b9a7c2d4e6d0 | Lisa | Garcia | lgarcia@example.com | (555) 456-7890 |
Analysis: This query successfully retrieves all members of a specific segment with comprehensive contact information. The results show:
- Segment membership: 5 total members in the queried segment
- Contact completeness: All members have both email addresses and phone numbers
- Geographic diversity: Phone numbers show different area codes, suggesting a diverse customer base
- Data quality: Consistent email format and complete contact information across all members
Recommendations:
- Use this query to validate segment membership and contact information accuracy
- Monitor segment membership growth over time
- Consider segment size limits for optimal targeting and performance
- Validate that all members have the expected contact information for campaign execution
- Review segment membership regularly to ensure relevance and accuracy
List Available Segments
This query answers: What marketing segments are available for activation in this Data Space?
-- Check what segments are available in your instance
SELECT
ms."ssot__Id__c" AS segment_id,
ms."ssot__Name__c" AS segment_name,
ms."ssot__Description__c" AS segment_description
FROM "ssot__MarketSegment__dlm" ms
ORDER BY ms."ssot__Name__c";
Sample Output
segment_id | segment_name | segment_description |
---|---|---|
1sgHo000000g1H2IAI | Bought Sunglasses Without Prescription | |
1sgHo000000g1H7IAI | test | |
1sgHo000000g1HWIAY | test individual | |
1sgHo000000g1NUIAY | test segment membership DMO |
Analysis: This query lists all available segments in your Data Cloud instance. The results show:
- Business segments: One meaningful business segment ("Bought Sunglasses Without Prescription") for targeting customers
- Test segments: Three test segments indicating ongoing development and testing activities
- Missing descriptions: All segments lack descriptions, which could impact usability and maintenance
- Segment variety: Mix of business and test segments suggests a development environment
Recommendations:
- Add descriptions to all segments for better documentation and maintenance
- Consider cleaning up or archiving test segments that are no longer needed
- Review segment naming conventions for consistency
- Document the business logic behind the "Bought Sunglasses Without Prescription" segment
System Health & Overview
Use these queries to get a high-level view of your Data Cloud instance, including record counts, data source contributions, and data ingestion trends.
Record Count of All Key Objects
This query answers: How many records exist for key objects in my Data Cloud instance? It counts total records for Individual, Unified Individual, and related objects to help you assess data volume and validate record distribution.
Party Identification Checkbox: Only check "Include Party Identification" if your Data Cloud instance uses Party Identification objects for identity resolution. If you're not using Party Identification (which is common for most standard implementations), leave this unchecked to avoid querying 'non-existent' tables.
Options:
SELECT '1' as "Order", 'Individual' as "Object", COUNT(*) AS "Count" FROM "ssot__Individual__dlm"
UNION
SELECT '2', 'Unified Link Individual' , COUNT(*) FROM "IndividualIdentityLink__dlm"
UNION
SELECT '3', 'Unified Individual', COUNT(*) FROM "UnifiedIndividual__dlm"
ORDER BY "Order";
Sample Output
Order | Object | Count |
---|---|---|
1 | Individual | 721 |
2 | Unified Link Individual | 721 |
3 | Unified Individual | 701 |
Analysis: This query provides a high-level overview of your Data Cloud instance health. The results show:
- Data volume: 721 Individual records with corresponding Unified Link Individual records
- Identity resolution success: 701 Unified Individual records created from 721 source records (97.2% success rate)
- Data integrity: Perfect 1:1 mapping between Individual and Unified Link Individual records
- Unification efficiency: 20 records were successfully unified into existing profiles, reducing duplication
Recommendations:
- Monitor the 20-record difference to ensure identity resolution is working optimally
- Track these counts over time to identify data ingestion trends
- Consider setting up alerts for significant changes in record counts
- Validate that the 97.2% unification rate meets business expectations
Record Counts by Data Source
These queries show which data sources are contributing the most records to the Individual and Unified Link Individual objects. This is useful for monitoring data ingestion volume from each connected source.
Individual Object
This query answers: Which data sources are contributing the most records to the Individual object?
-- Get a count of records in the Individual Object broken down by Data Source & Data Source object
SELECT
i."ssot__DataSourceId__c" AS data_source_id,
i."ssot__DataSourceObjectId__c" AS data_source_object_id,
COUNT(*) AS record_count
FROM "ssot__Individual__dlm" i
GROUP BY
i."ssot__DataSourceId__c",
i."ssot__DataSourceObjectId__c"
ORDER BY record_count DESC;
Sample Output
data_source_id | data_source_object_id | record_count |
---|---|---|
Salesforce_Home | Lead | 377 |
UploadedFiles | 'contact.csv' | 200 |
Salesforce_Home | Contact | 144 |
Unified Link Individual Object
This query answers: How many records are being processed by identity resolution from each data source?
-- Get a count of records in the Unified Link Individual Object broken down by Data Source & Data Source object
SELECT
iil."ssot__DataSourceId__c" AS data_source_id,
iil."ssot__DataSourceObjectId__c" AS data_source_object_id,
COUNT(iil."SourceRecordId__c") AS record_count
FROM "IndividualIdentityLink__dlm" iil
GROUP BY
iil."ssot__DataSourceId__c",
iil."ssot__DataSourceObjectId__c"
ORDER BY record_count DESC;
Sample Output
data_source_id | data_source_object_id | record_count |
---|---|---|
Salesforce_Home | Lead | 377 |
UploadedFiles | 'contact.csv' | 200 |
Salesforce_Home | Contact | 144 |
Data Ingestion Trends
Monitor data ingestion and unification volume over time to identify trends or anomalies.
Unified Individual Record Count by Date (Last 30 Days)
This query answers: How many new Unified Individual records were created each day over the past 30 days?
-- Track daily record creation for Unified Individuals
SELECT
DATE(ui."ssot__CreatedDate__c") AS created_date,
COUNT(*) AS record_count
FROM "UnifiedIndividual__dlm" ui
WHERE ui."ssot__CreatedDate__c" >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY DATE(ui."ssot__CreatedDate__c")
ORDER BY created_date DESC;
Sample Output
created_date | record_count |
---|---|
2025-07-10 | 501 |
2025-07-09 | 487 |
2025-07-08 | 452 |
Analysis: This query tracks daily Unified Individual record creation trends. The results show:
- Consistent growth: Daily record creation is increasing (452 → 487 → 501 records)
- High volume: Average of 480+ records per day indicates active data ingestion
- Recent activity: All data is from July 2025, suggesting recent system deployment or data migration
- Stable pattern: Consistent daily volumes suggest reliable data ingestion processes
Recommendations:
- Monitor for unusual spikes or drops in daily record creation
- Set up alerts for days with zero record creation (potential data ingestion issues)
- Track this trend over longer periods to identify seasonal patterns
- Validate that daily volumes align with expected business activity
Unified Individual Data Growth Trend (Month-over-Month)
This query answers: What is the month-over-month growth trend for Unified Individual records?
-- Analyze monthly growth of individual records
SELECT
DATE_TRUNC('month', ui."ssot__CreatedDate__c") AS month,
COUNT(*) AS record_count,
COUNT(*) - LAG(COUNT(*)) OVER (ORDER BY DATE_TRUNC('month', ui."ssot__CreatedDate__c")) AS growth
FROM "UnifiedIndividual__dlm" ui
WHERE ui."ssot__CreatedDate__c" >= CURRENT_DATE - INTERVAL '12 months'
GROUP BY DATE_TRUNC('month', ui."ssot__CreatedDate__c")
ORDER BY month;
Sample Output
month | record_count | growth |
---|---|---|
2025-07-01 | 501 | 76 |
2025-06-01 | 425 | 105 |
2025-05-01 | 320 | null |
Analysis: This query analyzes month-over-month growth trends for Unified Individual records. The results show:
- Strong growth: 76% increase from June to July (425 → 501 records)
- Accelerating growth: 105% increase from May to June (320 → 425 records)
- Recent deployment: Data starts in May 2025, indicating a relatively new Data Cloud implementation
- Growth pattern: Consistent month-over-month growth suggests successful data ingestion and identity resolution
Recommendations:
- Monitor growth rates to ensure they align with business expansion expectations
- Investigate the accelerating growth pattern to understand contributing factors
- Set up growth rate alerts to identify potential data quality issues
- Plan capacity and performance monitoring based on current growth trends
Identity Resolution Analysis
Dive deep into how identity resolution is performing in your instance. These queries help you find and investigate matched profiles, analyze match complexity, and identify critical data integrity issues.
Find Unified Profiles with Multiple Source Records (Overview)
This query answers: Which Unified Individuals were created by merging more than one source record? It helps identify profiles that are the result of identity resolution consolidation.
-- Shows Unified Individuals where more than 1 record was unified to create that unified individual
SELECT
iil."UnifiedRecordId__c" AS unified_individual_id,
COUNT(iil."CreatedDate__c") AS match_count,
ARRAY_TO_STRING(ARRAY_AGG(iil."SourceRecordId__c"), ', ') AS individual_ids
FROM "IndividualIdentityLink__dlm" iil
GROUP BY iil."UnifiedRecordId__c"
HAVING COUNT(iil."CreatedDate__c") > 1
ORDER BY match_count DESC;
Sample Output
unified_individual_id | match_count | individual_ids |
---|---|---|
c9bc41b37dd8440a45fe84e7f32639ec | 3 | 003Ho000025wcHNIAY, 00QHo000010wWftMAE, 00QHo000010wWdGMAU |
1ec4b440c15983687e41bc4628b6d21e | 2 | 003Ho000025wcHNIAY, 00QHo000010wWftMAE |
ffb8dadf482c2b0dde73c7782074470e | 2 | 003Ho000025wcFIIAY, 00QHo000010wWdGMAU |
1e91e9f54645600d22ae579afaa68883 | 2 | 003Ho000025wcFIIAY, 00QHo000010wWdGMAU |
52e31411a33e697c3f802485b90452c1 | 2 | 003Ho000025wcHOIAY, 00QHo000010wWeCMAU |
Analysis: This query identifies Unified Individuals created by merging multiple source records. The results show:
- Complex matches: One profile with 3 matched records, four profiles with 2 matched records
- Identity resolution working: Successfully consolidating duplicate records into unified profiles
- Data source variety: Mix of Contact and Lead records being unified
- Match quality: All matches appear to be legitimate (same person across different data sources)
Recommendations:
- Review the 3-record match to ensure all records belong to the same person
- Monitor match complexity to ensure identity resolution rules are optimal
- Investigate why some individuals have both Contact and Lead records
- Consider adjusting identity resolution rules if match rates are too high or low