DISTINCT Keyword in SQL

Level 239 keystrokes

DISTINCT removes duplicate values from the result set.

SQL code

1SELECT
-- DISTINCT returns each category value only once
2 DISTINCT category
-- Reads from products; without ORDER BY the row order may differ
3FROM
4 products;

Output

+-------------+
| category    |
+-------------+
| Electronics |
| Clothing    |
| Books       |
+-------------+
3 rows in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • ;× 1

More SQL examples at level 2

← SQL typing practice