Skip to main content

Unique values


Let's assume we have the following table

sales

 countrycityamount
1PolandWarsaw13
2GermanyBerlin24
3PolandKatowice56

And we would like to know all of the countries that the product was sold.

If we use the normal query we know: SELECT country from sales it will return Poland Germany Poland. This is not what we are looking for because Poland is repeated twice.

To solve it we can use the DISTINCT keyword:

SELECT DISTINCT country FROM sales