SQL select distinct statement
Duplicate values may be included in the table. This is not a problem, but sometimes you may want to list only distinct values.
The keyword distinct is used to return a unique different value
Select distinct column name from table name
Use the distinct keyword
To select all the values from the company column, we need to use the select statement:
SELECT Company FROM Orders
Take a closer look. In the result set, w3school is listed twice.
To select only the only different value from the company column, we need to use the select distinct statement:
SELECT DISTINCT Company FROM Orders
Now, “w3school” is listed only once in the result set