SQL DISTINCT

Last updated: August 27, 2026.

SELECT DISTINCT removes duplicate result rows after the selected expressions have been evaluated.

Syntax

SELECT DISTINCT column_name
FROM table_name;

Example

SELECT DISTINCT City, State
FROM EmployeeAddressTable
ORDER BY State, City;

Distinct applies to the complete selected row, not independently to each column. If you need counts, use COUNT(DISTINCT column_name) where your database supports it.

See the current PostgreSQL SQL reference; confirm dialect details for your own database.

admin

admin

Leave a Reply

Your email address will not be published.