# EXCEPT

EXCEPT keeps a row from the left input only when it does not occur in the right input. Repeated copies are removed. `EXCEPT ALL` is not supported.

## Syntax

```text
query EXCEPT query
[ORDER BY expression, ...]
[LIMIT count [OFFSET offset]]
```

Both inputs must return the same number of columns. Result column names come from the first query. Duplicate comparison applies to whole rows; `NULL` is equal to another `NULL` for this purpose.

A final `ORDER BY` or `LIMIT` applies to the combined result. Set operators at the same query level are evaluated from left to right. Put a nested query in a FROM subquery when a different grouping is needed.

## Example

### Combining two sets of identifiers

```sql
CREATE TABLE first_set (id INTEGER);
INSERT INTO first_set VALUES (1), (2), (2), (3);

CREATE TABLE second_set (id INTEGER);
INSERT INTO second_set VALUES (2), (4);
```

```sql
SELECT id FROM first_set
EXCEPT
SELECT id FROM second_set
ORDER BY id
FORMAT csv;
```

```text
1
3
```

This set operator is separate from ClickHouse column-selection syntax such as `SELECT * EXCEPT column`, which is not supported.

See [`UNION`](https://coordinatordb.com/docs/reference/statements/select/union), [`INTERSECT`](https://coordinatordb.com/docs/reference/statements/select/intersect) and [`EXCEPT`](https://coordinatordb.com/docs/reference/statements/select/except) for the other set operations.
