SQL Select Distinct

The SELECT DISTINCT statement in SQL is used to retrieve unique values from a column or set of columns in a table. It helps to eliminate duplicate rows from the result set, ensuring that only distinct values are displayed.


SQL Select Distinct Syntax

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



SQL Select Distinct Examples

SQL Select Distinct Selecting Unique Values from a Single Column Example

This query retrieves a list of distinct specialty values from the doctors table. If multiple doctors have the same specialty, it will only show that specialty once.

SELECT DISTINCT specialty
FROM Doctors;



SQL Select Distinct Selecting Unique Combinations from Multiple Columns

This query retrieves unique pairs of first_name and last_name.

SELECT DISTINCT first_name, last_name
FROM Doctors;




SQL Select Distinct Visual Diagram




SQL Select Distinct Labs

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top