DISTINCT

A keyword that removes duplicate rows from a query's answer, or duplicate values inside an aggregate such as COUNT.

In more detail

DISTINCT applies to the whole answer row, so adding a second column usually brings duplicates back. Inside COUNT it counts different values, which is how you count orders rather than order lines after a join.

Examples

SELECT DISTINCT status FROM orders;
COUNT(DISTINCT customer_id)

Related terms

Taught in

References