---
cuppy_hub: salesforce
cuppy_path: reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/select-union.md
cuppy_section: docs
cuppy_doc: 2106-ZS8T
cuppy_doc_uuid: f125634b-da80-4dc8-9db3-d35bbae9abd7
cuppy_permalink: https://cuppy.io/salesforce/d/2106-ZS8T
cuppy_version: 1
cuppy_updated: 2026-10-23T16:16:52.575Z
cuppy_canonical: https://cuppy.io/salesforce/docs/reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/select-union
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: 317d942386e7f26d32c9639a462593b4fca0ab70591f4e86d3c9ad037068e2c8
# cuppy_body_sha256 is over the document body ALONE, excluding both generated blocks.
---

> Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/select-union.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.

## `UNION`, `INTERSECT`, and `EXCEPT` Operators

By using the operators `UNION`, `INTERSECT`, and `EXCEPT`, the output of more than one `SELECT` statement can be combined to form a single result set. The `<select_statement>` can’t have an `ORDER BY` or `LIMIT` clause. `ORDER BY` and `LIMIT` can be attached to a sub-expression if it’s enclosed in parentheses. Without parentheses, these clauses apply to the result of the `UNION`.

The result of these operators, by default, doesn’t contain duplicates. To return duplicates in the result, specify the `ALL` option.

Operators in the same `SELECT` statement are evaluated from left to right. Intersect binds more tightly than `UNION` or `EXCEPT`. For example, `A UNION B INTERSECT C` is read as `A UNION (B INTERSECT C)`.

The `UNION` operator computes the set union of the rows returned by the `SELECT` statements. A row is in the set union if it’s in at least one of the result sets. Provide two `SELECT` statements that produce the same number of columns, and have columns with compatible data types.

**Syntax**

The `INTERSECT` operator computes the set intersection of the rows returned by the `SELECT` statements. A row is in the intersection if it appears in both result sets. With the `ALL` option, a row that has `m` duplicates in the left table and `n` duplicates in the right table appears `min(m, n)` times in the result set.

**Syntax**

The `EXCEPT` operator computes the set of rows that are in the result of the left `SELECT` statement but not in the result of the right one. With `ALL`, a row that has `m` duplicates in the left table and `n` duplicates in the right table appears `max(m - n, 0)` times in the result set.

**Syntax**


---
<!-- cuppy -->
You are reading one file. The same content is free over MCP at https://cuppy.io/mcp with no signup: ranked search across all 376 documents in this hub, the merged view when you work in a layer, known workarounds matched to the error you hit, and depth control so you spend tokens on what you need. Start with the `_hello` tool. How to connect: https://cuppy.io/salesforce/ Something wrong in this document? Report it with the `session feedback` tool on the same endpoint.
<!-- /cuppy -->
