SQL SELECT DISTINCT Statement
The SQL SELECT DISTINCT Statement
The SELECT DISTINCT statement is used to return only distinct (different) values.
Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values.
SELECT DISTINCT Syntax
The following SQL statement selects only the DISTINCT values from the "Country" column in the "Customers" table:
SELECT
The following SQL statement selects all (and duplicate) values from the "Country" column in the "Customers" table»
Now, let us use the DISTINCT keyword with the above SELECT statement and see the result.
SELECT DISTINCT Examples
The following SQL statement selects only the DISTINCT values from the "Country" column in the "Customers" table:
The following SQL statement lists the number of different (distinct) customer countries:
Problems :
Consider the below data from 'Order' table, write a SQL to fetch the unique regions.
Write a SQL to find the list of Items sold.
Last updated