Distinct Check

Read this next to the plain SELECT duplicate page:

  1. Project the category column.
  2. Compare each projected row with the rows already kept.
  3. Keep the first copy of each category value and skip later equal copies. The tiny table is pinned so the dedup step is auditable. DISTINCT changes row count; it does not estimate, sample, or choose a "best" row.

SELECT DISTINCT is the explicit dedup boundary for projected rows.

highlighted = computed this step

Input table

Use the same category table with a repeated category.

Order categories\text{Order categories}
Order categoriesorder_idcategoryo1booko2booko3pen

Select query

DISTINCT projects the category column and collapses equal output rows.

SELECT DISTINCT category\text{SELECT DISTINCT category}
SELECT DISTINCT categorydistinct categoryarity 1 rows 2OrderCategoriesarity 2 rows 3

Output table

Each category value appears once in the output.

deduped output\text{deduped output}
Outputcategorybookpen