SQL SELECT DISTINCT Keyword

The SELECT DISTINCT statement in SQL is used to retrieve only unique values from a column or set of columns in a table. It eliminates duplicate rows from the result set, giving you a list of distinct values.



SELECT DISTINCT: Definition and Usage

SELECT DISTINCT is incredibly helpful when you only need a list of unique values and don't need to see repeated entries. This is common when you want to see a list of all available countries, product categories, or any other attribute where you are only interested in unique values.

Syntax

Syntax

SELECT DISTINCT column1, column2, ...
FROM table_name;
      

Example

Retrieving Distinct Countries

This query retrieves a list of unique countries from the 'Customers' table (assuming a table named 'Customers' exists with a 'Country' column).

Syntax

SELECT DISTINCT Country FROM Customers;
      
Output

Country
-------
USA     (Example - adapt to your data)
UK
Germany
France
...
      

**Note:** The example output shows a general structure. The specific countries and their order will depend on the data in your `Customers` table. The `...` indicates that additional unique country names would appear in a real-world result set.