SQL Distinct Clause - How to use Distinct in SQL



Demo wikitechydatabase

  • Below is a selection from the wikitechytable table used in the examples:
sql-distinct-command-1

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

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

SELECT DISTINCT Examples

  • The following SQL statement selects only the DISTINCT values from the "name" column in the "wikitechytable" table:
SELECT DISTINCT name FROM wikitechytable

Output

sql-distinct-command-2

Related Searches to SQL Distinct Clause - How to use Distinct in SQL