SQL – Select Distinct Statement
Table Of Contents:
- What Is Select Distinct Statement?
- Syntax Of Select Distinct.
- Examples Of Select Distinct.
(1) What Is Select Distinct Statement ?
- The
SELECT DISTINCT
the statement is used to return only distinct (different) values. - Inside a table, a column often contains many duplicate values; sometimes you only want to list the different (distinct) values.
(2) Syntax Of Select Distinct.
SELECT DISTINCT column1, column2, ...
FROM table_name;
(3) Examples Of Select Distinct.
Demo Data
Example-1: Select Only Different Country Names
SELECT DISTINCT Country FROM Customers;
Example-2: Select a Different City and Country Combination.
SELECT DISTINCT City, Country FROM Customers;
Example-3: Select Count Of Different Country
SELECT COUNT(DISTINCT Country) FROM Customers;