# SQL query segmentation across data extensions

*Marketing Cloud Engagement Specialist Study Guide · Subscriber and Data Management · Last updated October 29, 2026 · https://www.certifyforce.com/study-guide/marketing-cloud-engagement-specialist/subscriber-and-data-management/sql-query-segmentation-across-data-extensions*

When a SQL Query activity beats a data filter, which SQL the activity supports (joins and nested queries yes; CTEs, temporary tables and variables no), how to aggregate with GROUP BY and HAVING, draw a random sample with TOP n PERCENT and NEWID(), and reach shared data extensions with ENT. and the data extension name.

- Certification: Salesforce Marketing Cloud Engagement Specialist
- Exam section: Subscriber and Data Management
- Study guide: https://www.certifyforce.com/study-guide/marketing-cloud-engagement-specialist

**Official exam objective:**

> Given a customer's business requirements, configure segmentation tools to model subscribers and data.

## What the exam expects

- Choose a SQL Query activity over a data filter when a segment needs more than one data extension.
- Recognize supported and unsupported SQL in the activity, and rewrite unsupported constructs.
- Write aggregate and random-sample segments with GROUP BY, HAVING, TOP n PERCENT and NEWID().
- Reference shared and parent-account data extensions correctly in an Enterprise 2.0 account.
- Key terms: **SQL Query activity** (Automation Studio activity that runs a SELECT and writes to a target data extension); **target data extension** (where results land; can't be a source of the same query); **nested query** (a subquery inside another statement); **ENT. prefix** (reaches shared or enterprise parent data extensions).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Query versus filter | Queries evaluate more than one data extension at a time | [Automate Audience Segmentation](https://trailhead.salesforce.com/content/learn/modules/audience-segmentation/automate-audience-segmentation) |
| Filter activity result | Refreshes each time the activity runs | [Automate Audience Segmentation](https://trailhead.salesforce.com/content/learn/modules/audience-segmentation/automate-audience-segmentation) |
| Target data extension | Created before the query activity | [Build a SQL Query Activity](https://help.salesforce.com/s/articleView?id=mktg.mc_as_use_the_sql_query_activity.htm&language=en_US&type=5) |
| Nested queries | Supported | [SQL Reference](https://help.salesforce.com/s/articleView?id=mktg.mc_as_sql_reference.htm&language=en_US&type=5) |
| CTEs, temp tables, variables | Unsupported | [SQL Reference](https://help.salesforce.com/s/articleView?id=mktg.mc_as_sql_reference.htm&language=en_US&type=5) |
| NOLOCK | Unnecessary; queries run READ UNCOMMITTED | [SQL Reference](https://help.salesforce.com/s/articleView?id=mktg.mc_as_sql_reference.htm&language=en_US&type=5) |
| Random share | TOP n PERCENT with ORDER BY newid() | [SQL Reference](https://help.salesforce.com/s/articleView?id=mktg.mc_as_sql_reference.htm&language=en_US&type=5) |
| Shared or parent data extension | ENT. prefix plus the data extension name, not the external key | [SQL Reference](https://help.salesforce.com/s/articleView?id=mktg.mc_as_sql_reference.htm&language=en_US&type=5) |

## Check yourself

- Which SQL Server version is the activity based on?
- Why is adding WITH (NOLOCK) to a query pointless?
- When will the activity run a statement at all?
- Which procedural keywords besides variables does the reference list as unsupported?

## Sources

- [SQL Reference](https://help.salesforce.com/s/articleView?id=mktg.mc_as_sql_reference.htm&language=en_US&type=5)
- [Build a SQL Query Activity](https://help.salesforce.com/s/articleView?id=mktg.mc_as_use_the_sql_query_activity.htm&language=en_US&type=5)
- [Automate Audience Segmentation Techniques](https://trailhead.salesforce.com/content/learn/modules/audience-segmentation/automate-audience-segmentation)
- [Segmentation Tools for Marketing Optimization](https://trailhead.salesforce.com/content/learn/modules/audience-segmentation/learn-about-segmentation-tools)
- [Data Filter Definition for Marketing Cloud Engagement](https://help.salesforce.com/s/articleView?id=sf.mc_es_data_filter_definition.htm&language=en_US&type=5)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 6 linked practice questions, and unlimited timed mock exams are included with the Marketing Cloud Engagement Specialist pack (USD $19): https://www.certifyforce.com/practice-exams
