Home › Learn › SQL › Shaping results

DISTINCT

Lesson 6 of 26. Each value once.

SELECT DISTINCT category FROM products; returns each category once, however many products it has. DISTINCT applies to the whole row of selected columns, so SELECT DISTINCT category, price returns each different combination.

It is the quick way to answer "what values does this column contain?"; counting how many rows each value has is the job of GROUP BY, which comes in the next module.

SELECT DISTINCT dept FROM employees;

Your task

List each product category once.

Hint 1

Put DISTINCT right after SELECT.

Show the solution
SELECT DISTINCT category FROM products;

    Runs SQLite compiled to WebAssembly in this tab; the database is rebuilt before every run.